React Recursive - Set state from parent reset all recursive tree to initial value

37 views Asked by At

Im currently doing a treeview table data. So the recursive part is fine until i passing component with parent state to it. In this example im passing 2 checkbox. The first one is adding the tree item to a list and if the item are on the list it will cheked, the second one doing nothing. So the problem is when i expand tree and check the 2nd checkbox it seem fine but when i start to check the first one where the logic are. The tree seem to be reset to it initial value, all tree collapse and all the non-logic checkbox are uncheked. So what am i missing here or is there any solution. Im try to passing unique key so react won't rerender item that don't change but it seem to do nothing. Or im doing it wrong?

My code: https://codesandbox.io/s/festive-kapitsa-rx56jr?file=/src/App.tsx

0

There are 0 answers