react-d3-tree
react-d3-tree copied to clipboard
how to edit the node ?
trafficstars
Thank you for taking the time to report an issue with react-d3-tree!
Feel free to delete any questions that do not apply.
Are you reporting a bug, or opening a feature request?
[Replace with your answer]
What is the actual behavior/output?
[Replace with your answer if relevant]
What is the behavior/output you expect?
[Replace with your answer if relevant]
Can you consistently reproduce the issue/create a reproduction case (e.g. on https://codesandbox.io)?
[Replace with your answer if relevant]
What version of react-d3-tree are you using?
[Replace with your answer]
If react-d3-tree crashed with a traceback, please paste the full traceback below.
[Replace with your traceback]
You need to do a few things.
- Manage the tree data as a state in your code
- Use the callback for onMouseOver to get the nodeData, then extract the name of the node
- Use the name of the node to search through the tree data object (I used recursive depth first search). Once you've found it, update the node data. Be sure to return the modified tree data object
- Update the tree data state with the modified tree data object, which will essentially "redraw" the tree
This is what I did from a high level perspective. If anyone has a simpler way please chime in