lukasbach / react-complex-tree

Unopinionated Accessible Tree Component with Multi-Select and Drag-And-Drop
https://rct.lukasbach.com
MIT License
952 stars 77 forks source link

Tree data is not shown when i use deepClone react state #230

Closed JongSikLim closed 1 year ago

JongSikLim commented 1 year ago

Describe the bug Hello, I'm developing a service that supports add/delete/copy/move tree items using your library. Previously, I was putting react state values in StaticTreeDataProvider, but I noticed that the state values were changing unintentionally due to references in the data, so I tried to break the references through lodash's deepClone to solve it.

However, while doing so, I encountered an issue where I couldn't see a single tree item.

Additionally, I noticed that whenever I update treeDatas, the items inside the treeDataProvider are reflected normally. I also noticed that the renderProps method was not being called.

To Reproduce Steps to reproduce the behavior:

const copiedData = cloneDeep(treeDatas);
const treeDataProvider = new StaticTreeDataProvider(copiedData);

return <UncontrolledTreeEnvironment dataProvider={treeDataProvider}> ...

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):