gantt-task-react
gantt-task-react copied to clipboard
Add task dynamically
Is it possible to add new tasks dynamically or to delete tasks. Also, would be good if there is support to have scheduling tasks by priority from UI itself.
Updating the tasks via setTasks will cause a rerender of the chart.
useEffect(() => {
setTimeout(() => {
// make copy of tasks otherwise it will not cause a re-render of chart
const nt = [...tasks];
const currentDate = new Date();
// add the item to the array but could easily be updating an item
nt.push({
start: new Date(currentDate.getFullYear(), currentDate.getMonth(), 25),
end: new Date(currentDate.getFullYear(), currentDate.getMonth(), 26),
name: "Party Time 2",
id: "Task 10005",
progress: 0,
isDisabled: true,
type: "task",
});
// set tasks
setTasks(nt);
}, 5000);
}, []);
Updating the tasks via setTasks will cause a rerender of the chart.
any solution for rerender of the chart ?