MrBlenny / react-flow-chart

🌊 A flexible, stateless, declarative flow chart library for react.
https://mrblenny.github.io/react-flow-chart/index.html
MIT License
1.46k stars 307 forks source link

onCanvasDrop creates two nodes #122

Closed Livshind15 closed 4 years ago

Livshind15 commented 4 years ago

because of React.StrictMode setState updaters will run twice in strict mode in development, This causes a double call to onCanvasDrop function and create double node

daveabes commented 4 years ago

Yes I was experiencing the same issue. When structuring my components differently from the examples, the on Node Dropped event is called 2 times.

MrBlenny commented 4 years ago

What do you suggest the solution to this is?

prativm commented 4 years ago

@MrBlenny
Experiencing the same issue. it creates two nodes with different IDs.

ChrisCardoz commented 4 years ago

@MrBlenny I noticed the error occurring when I started to useContext() for the state of my graph according to this example. https://codesandbox.io/embed/condescending-moon-jke7z

When I used this model for the state of the graph, I couldn't figure out how to update the state of the graph from the node, but I did not experience this error. https://github.com/MrBlenny/react-flow-chart/blob/master/stories/CustomNodeInner.tsx