bkrem / react-d3-tree

:deciduous_tree: React component to create interactive D3 tree graphs
https://bkrem.github.io/react-d3-tree
MIT License
1.06k stars 268 forks source link

Additional Methods To Node Class's Internal Handlers #462

Open dev-john-nguyen opened 1 year ago

dev-john-nguyen commented 1 year ago

Enhancements

The purpose of these enhancements is to give the user the ability to make dynamic updates to the tree without completely re-rendering the whole tree.

Use Case

Handling dynamic updates like removing a node, combining nodes, and renaming nodes.

Node Class's Internal Handlers

removeNode: () => void

replaceChildren: (children: RawNodeDatum[]) => void

updateNodeAttributes: (attributes: Omit<RawNodeDatum, 'children'>) => void

Additional

Updated the key value for Node to be more unique ( key={'node-' + hierarchyPointNode.data.__rd3t.id} ). Since the tree will be dynamically updating, we want the key to be unique to it's node instead of using index to prevent buggy behavior.