array-to-tree icon indicating copy to clipboard operation
array-to-tree copied to clipboard

Maximum call stack size exceeded

Open Protonex opened this issue 7 years ago • 3 comments

When data had 2 or more top levels 'root' there is stack overflow occured. Here is representation:

https://repl.it/@Nexis/NotableElegantLaws

Just remove top root level and all works fine.

Protonex avatar Nov 02 '18 18:11 Protonex

The same issue here

vosho avatar Dec 15 '18 15:12 vosho

It seems that problem is in "ParentId": 0 Lib considers it as undefined.

ramax495 avatar Apr 25 '19 12:04 ramax495

The default rootID value is '0'. According to the source code analysis, if the customID and rootID passed in the data are repeated. Then this problem will occur. Therefore, I think a better solution is to customize the rootID configuration to ensure that the rootID is unique. such as const tree = arrayToTree(array, { parentProperty: 'ParentId', customID: 'Id', rootID: 'root' });

sheerLi avatar Apr 14 '20 04:04 sheerLi