react-flowchart icon indicating copy to clipboard operation
react-flowchart copied to clipboard

adding/removing nodes

Open dspnorman opened this issue 10 years ago • 2 comments

Curious if this functionality is being worked on at all.

dspnorman avatar Dec 08 '15 17:12 dspnorman

I think add / remove is out of the scope of what react-flowchart is doing. Because you are passing in an array that is then rendered out into a drag+drop gui, the parent component to react-flowchart is the owner of that array, so react-flowchart shouldn't be changing that array.

Setup an "add" function on your parent component that adds to the array you are passing into react-flowchart, and then re-render react-flowchart with the modified array.

For "remove", create a function on the NodeContents component that you are passing in. In my implementation, that "remove" function emits an event that the parent component listens for and then modifies the array.

All of the manipulation of the data set that you are passing into react-flowchart should occur in the parent component that is using react-flowchart.

wunderlink avatar Dec 09 '15 00:12 wunderlink

By the way, thanks for playing with this! Sorry for the crappy documentation >.<

wunderlink avatar Dec 09 '15 00:12 wunderlink