react-d3-tree icon indicating copy to clipboard operation
react-d3-tree copied to clipboard

how to edit the node ?

Open umars2204 opened this issue 5 years ago • 1 comments
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]

umars2204 avatar Sep 18 '20 08:09 umars2204

You need to do a few things.

  1. Manage the tree data as a state in your code
  2. Use the callback for onMouseOver to get the nodeData, then extract the name of the node
  3. 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
  4. 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

franklx2 avatar Oct 01 '20 11:10 franklx2