minop1205 / react-dnd-treeview

A draggable / droppable React-based treeview component. You can use render props to create each node freely.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete item

dgtllion opened this issue · comments

Hi, is there a way to delete an item? If i put tree into state and pass the state to Tree afterwards remove an item the render isnt triggered. So the object is gone from the state but nothing is changed in DOM.
Is there a way how can i fix it?

I think it will work if you use an immutable function when generating new tree states.

Try the following sample.
Enter the ID in the text field and click the REMOVE button, and the node with the corresponding ID should be deleted.

In this example, the filter method is used to generate a new node array.

https://codesandbox.io/s/full-features-js-forked-823jq?file=/src/App.jsx

ah i see... i delete item from context menu witch doesnt got reference to my App... Now fixed it ;) Thanks a lot for you example!