minop1205 / react-dnd-treeview

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

Add the parent index and the current node index to props #119

Closed zetorby closed 2 years ago

zetorby commented 2 years ago

How can get the index of the parent and the current node to number such a list? image

minop1205 commented 2 years ago

@zetorby Even if parent index or current index is given to render, it may not be enough to obtain the expected prefix if the tree hierarchy is deep.

In any case, it is necessary to go back to the root node to get the index of each hierarchy, so please implement the logic in your application as shown in the example below.

https://codesandbox.io/s/issue-119-l81c14?file=/src/App.tsx

zetorby commented 2 years ago

@minop1205 Thank you for your help