You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using React Gantt, when updating the store with the stm enabled, it triggers an Id duplicate error. It looks only with this configuration in the project model
Makes react think it needs to re-render the whole Table component. (That is why the bug disappears when this line setCanUndo(projectModel.current.stm.canUndo) is commented.) Then, the whole Table constructor is called for that purpose.
2) This is already an expected thing, as it will create a new instance of ProjectModel using the same initial data. More over , the datais exactly the same object, that was used during the initial data load (from initial rendering).
3) Then, it seems our transformFlatData code mutates that object in-place so that the flat list:
becomes a tree structure by moving the Child task into the children of Parent, but it keeps reference to the original object where it was, so the data looks like this:
const data = [
{ id: 1, name: "Parent", status: 'doing', startDate: new Date(), children : [ REF_TO_CHILD ] },
{ id: 2, name: "Child", status: 'doing' },
];
When loading the data, the Parent task goes first and all its children, so processing Parent will also pull in the Child
The Child is attempted to be pulled in again from the 2nd position in the data array, producing the exception.
This is why, the initial loading is performed w/o errors (the data is not yet mutated), but the subsequent attempts to load with the same data object will throw.
I think the transformFlatData code should not mutate the data - will try to remove that and see if that breaks any other code.
Forum post
Using React Gantt, when updating the store with the stm enabled, it triggers an Id duplicate error. It looks only with this configuration in the project model
I also attached a sample project to reproduce the error
basic.zip
The text was updated successfully, but these errors were encountered: