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
In most cases, our tree list contains a row whose parentId field is one of null / undefined / '', but if the tree list is a subset of original tree list, chances are that the transform result is not right, no matter the throwIfOrphans option is set to true or false
example:
import{arrayToTree}from'performant-array-to-tree'constlist=[{id: "aaa",parentId: "notexist"},{id: "bbb",parentId: "aaa"},{id: "ccc",parentId: "bbb"},{id: "ddd",parentId: "bbb"},];constresult=arrayToTree(list,{dataField: null,});console.log(JSON.stringify(result,null,2));// the output is []
Suggestion
If we add an option named rootParentId, items whose parentId equals rootParentId will be treat as a root item.
All tests passed but it seems there is something wrong with circle ci config. Runing yarn run test-and-send-cov-to-coveralls, ci gives Bad response: 422 {"message":"Couldn't find a repository matching this job.","error":true} response.
So the build is blocked
Why
In most cases, our tree list contains a row whose
parentId
field is one ofnull
/undefined
/''
, but if the tree list is a subset of original tree list, chances are that the transform result is not right, no matter thethrowIfOrphans
option is set totrue
orfalse
example:
Suggestion
If we add an option named
rootParentId
, items whoseparentId
equalsrootParentId
will be treat as a root item.The above code's output should be like this
How
Add
rootParentId
into option, then replacewith
Of course we can also make
rootParentId
an array, the initial value is [null, undefined, ''] and will later be merged with user defined rootParentIdsThe text was updated successfully, but these errors were encountered: