react-checkbox-tree
react-checkbox-tree copied to clipboard
Allow to rename value directly from the tree
Hi guys, my request is the below: there is a way to change the single node value directly from the tree? I've searched and I've tried to change the value creating a localstorage service where I store the tree JSON and then pass all the changes by modal. When the callback is done, the localstorage is correctly update and also all files needed to render the tree, BUT, the tree inside the page still remain to old input. Only refreshing the page the new value appear. Render is ok when the callback is done.
So the new feature will be to change directly the node name, what do you think about it?
Thank you,
There is no way to rename a node within the component itself. That is a potential new feature to add.
However, you certainly can change the name of the nodes on-the-fly (such as through a modal as you describe) and update the component to reflect those changes. See this example.
You have to make sure that React knows that it needs to re-render the tree. The example above uses the standard setState to signal a change to React and thus trigger the Tree to redraw the labels.
I understood, yep will be a good feature and yes, with play with setState and "straggling" a bit, I'm able to change on-the-fly the value and the label.
@alessandronocera89 would you tell how did you achieve it?