I need help. I've got this code snippet: https://codesandbox.io/s/modern-fog-495lq?file=/src/App.js - there is a problem with expansion of my two tree items. I need to have state of my expansion tree (Child) in Parent Component, but now all of my tree items are expanded/not expanded concurentlly because of the state in Parent Component. Is there any solution to solve this problem? To have expand only one tree when it's clicked on? Thank you for your help.
CodePudding user response:
Issue
This is happening because you use one state variable for both children. One child triggers the other.
Solution
Instead of a flag, keep an array, and push to array on expand, filter out on shrink