Hello,
We use React's State hook (useState) to store and update values for tasks.
And we want to implement functionality to update start and end dates of the task.
There is no problem in updating the endDate, I just set a new value to the endDate and see the changes in the UI but when I update the startDate, I see that Start Date is changed for a moment but than it reverts back to the initial value.
Could you please help me to find a right way hot to properly update startDate value for a task?
const [tasksState, setTasksState] = useState<TaskModel[] | Partial<TaskModelConfig>[]>([]);
useEffect(() => {
const tasks = [
{
"id": 1,
"name": "Setup web server",
"percentDone": 50,
"startDate": "2023-05-11",
"rollup": true,
"endDate": "2023-05-31",
"expanded": true,
"baselines": [
{
"startDate": "2023-05-13T23:00:00",
"endDate": "2023-05-16T23:00:00"
},
{
"startDate": "2023-05-13T23:00:00",
"endDate": "2023-05-16T23:00:00"
},
{
"startDate": "2023-05-13T23:00:00",
"endDate": "2023-05-16T23:00:00"
}
]
}
];
setTasksState(tasks);
}, [])
const clickHandler = () => {
const tasks = tasksState.map(t => t.id === 1 ? { ...t, startDate: '2023-05-20' } : t);
setTasksState(tasks);
}
<BryntumGantt
ref={gantt}
tasks={tasksState}
{...ganttConfig}
/>