minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.
MIT License
516 stars 69 forks source link

'Maximum call stack size exceeded' error when trying to add a small number of nodes #203

Closed developergunny closed 1 year ago

developergunny commented 1 year ago

'Maximum call stack size exceeded' error when trying to add a small number of nodes

I am creating a tree by transforming dynamic json data into node form. In fact, it works well when transformed and rendered with about 200 nodes, but an error occurs in the tree library after binding 38 node data.

Node data can be provided if desired.

(38) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {id: 'legos', rootId: 'composite', originalId: 'legos', parent: 'root', droppable: true, …}
1: {id: 'list-0', rootId: 'composite', originalId: 'list', parent: 'legos', droppable: true, …}
2: {id: 'id-unknown-0', rootId: 'composite', originalId: '', parent: 'list-0', droppable: false, …}
3: {id: 'switch-1', rootId: 'composite', originalId: 'switch', parent: 'list-0', droppable: true, …}
4: {id: 'c44b91f0-13fb-11ee-8191-e921c457342a', rootId: 'composite', originalId: 'case', parent: 'switch-1', droppable: false, …}
5: {id: 'c44b91f1-13fb-11ee-8191-e921c457342a', rootId: 'composite', originalId: 'case', parent: 'switch-1', droppable: false, …}
6: {id: 'line-2', rootId: 'composite', originalId: 'line', parent: 'list-0', droppable: false, …}
7: {id: 'grid-3', rootId: 'composite', originalId: 'grid', parent: 'list-0', droppable: true, …}
8: {id: 'list-0', rootId: 'composite', originalId: 'list', parent: 'grid-3', droppable: true, …}
9: {id: 'id-unknown-0', rootId: 'composite', originalId: '', parent: 'list-0', droppable: false, …}
10: {id: 'id-unknown-1', rootId: 'composite', originalId: '', parent: 'list-0', droppable: false, …}
11: {id: 'grid-1', rootId: 'composite', originalId: 'grid', parent: 'grid-3', droppable: true, …}
12: {id: 'list-0', rootId: 'composite', originalId: 'list', parent: 'grid-1', droppable: true, …}
13: {id: 'id-unknown-0', rootId: 'composite', originalId: '', parent: 'list-0', droppable: false, …}
14: {id: 'id-unknown-1', rootId: 'composite', originalId: '', parent: 'list-0', droppable: false, …}
15: {id: 'switch-1', rootId: 'composite', originalId: 'switch', parent: 'grid-1', droppable: true, …}
16: {id: 'c44b91f2-13fb-11ee-8191-e921c457342a', rootId: 'composite', originalId: 'case', parent: 'switch-1', droppable: false, …}
17: {id: 'c44b91f3-13fb-11ee-8191-e921c457342a', rootId: 'composite', originalId: 'case', parent: 'switch-1', droppable: false, …}
18: {id: 'variableText-1', rootId: 'composite', originalId: 'variableText', parent: 'legos', droppable: false, …}
19: {id: 'listByMeta-2', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
20: {id: 'variableText-3', rootId: 'composite', originalId: 'variableText', parent: 'legos', droppable: false, …}
21: {id: 'listByMeta-4', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
22: {id: 'listByMeta-5', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
23: {id: 'grid-6', rootId: 'composite', originalId: 'grid', parent: 'legos', droppable: true, …}
24: {id: 'varText-0', rootId: 'composite', originalId: 'varText', parent: 'grid-6', droppable: false, …}
25: {id: 'varText-1', rootId: 'composite', originalId: 'varText', parent: 'grid-6', droppable: false, …}
26: {id: 'listByMeta-7', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
27: {id: 'listByMeta-8', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
28: {id: 'button-9', rootId: 'composite', originalId: 'button', parent: 'legos', droppable: false, …}
29: {id: 'varText-10', rootId: 'composite', originalId: 'varText', parent: 'legos', droppable: false, …}
30: {id: 'listByMeta-11', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
31: {id: 'grid-12', rootId: 'composite', originalId: 'grid', parent: 'legos', droppable: true, …}
32: {id: 'varText-0', rootId: 'composite', originalId: 'varText', parent: 'grid-12', droppable: false, …}
33: {id: 'varText-1', rootId: 'composite', originalId: 'varText', parent: 'grid-12', droppable: false, …}
34: {id: 'listByMeta-13', rootId: 'composite', originalId: 'listByMeta', parent: 'legos', droppable: false, …}
35: {id: 'toolbar', rootId: 'composite', originalId: 'toolbar', parent: 'root', droppable: true, …}
36: {id: 'headerLego', rootId: 'composite', originalId: 'headerLego', parent: 'toolbar', droppable: true, …}
37: {id: 'title-0', rootId: 'composite', originalId: 'title', parent: 'headerLego', droppable: false, …}
length: 38

Uncaught RangeError RangeError: Maximum call stack size exceeded
    at <anonymous> (/Users/mac/Documents/workspace/?/node_modules/@minoru/react-dnd-treeview/dist/index.js:367:1)
    at search (/Users/mac/Documents/workspace/?/node_modules/@minoru/react-dnd-treeview/dist/index.js:367:1)
    at search (/Users/mac/Documents/workspace/?/node_modules/@minoru/react-dnd-treeview/dist/index.js:372:1)
    at search (/Users/mac/Documents/workspace/?/node_modules/@minoru/react-dnd-treeview/dist/index.js:372:1)
    eview/dist/index.js:372:1)
    at search (/Users/mac/Documents/workspace/?/node_modules/@minoru/react-dnd-treeview/dist/index.js:372:1)
    ....
minop1205 commented 1 year ago

@developergunny Thank you for your report. It would be helpful if you could provide me with the node data so I can check it.

developergunny commented 1 year ago

@minop1205

Here it is. JSON is long,I will send it as a text file.

tree_jsondata.txt

developergunny commented 1 year ago

Sorry for the inconvenience.

This is a problem caused by duplicate node ids.

I solved this.

Close the issue.

minop1205 commented 1 year ago

Yes, I have. I just checked too. I found a circular reference with the following IDs

I'm glad you solved it.