react-simple-tree-menu icon indicating copy to clipboard operation
react-simple-tree-menu copied to clipboard

On Click listener for expand/collapse button

Open impsinha opened this issue 3 years ago • 0 comments

Problem - Basically I want to control expand/collapse from both UI and outside UI. On setting openNodes params, I am able to expand/collapse from outside UI but I am not able to expand/collapse through UI.

Possible solution - If we have 'on click listener' for expand/collapse button, we will be able to maintain the state of openNodes params through useState and we will be able to set the openNodes state from 'on click listener' and outside as well.

Another possible solution would be to use useEffect to enforce the re-rendering the component from outside by using initialOpenNodes params but I am losing the previous openNodes state in that case.

In case, there is any workaround to achieve this in current version, please enlighten me.

impsinha avatar May 05 '22 14:05 impsinha