react-flow-chart icon indicating copy to clipboard operation
react-flow-chart copied to clipboard

Drag and drop of node inside canvas create two nodes in dev mode

Open edesmars opened this issue 4 years ago • 3 comments

While in dev mode, the reducer for the action onCanvasDrop will create two nodes instead of one. When creating a production build of the same application then it creates only one node in the state as expected.

I believe this is due to the fact that setState is called twice in dev mode to surface this kind of issues. The challenges probably comes from the uuid that create a different key in the object instead of recreating the same key hence the end result is two identical nodes being added.

Not sure what we can do to solve this as I'm pretty new in react.

edesmars avatar Jun 09 '20 17:06 edesmars

I was actually able to fix this issue by calculating myself the value for the next id outside of the Flow Chart prior to drag and drop and passing it to data.id. Hope it helps other people that come across that issue.

edesmars avatar Jun 10 '20 16:06 edesmars

Could you post a screenshot of the issue or explain how you can view it? I don't have the same issue

kcvin94 avatar Jun 18 '20 09:06 kcvin94

I have the same issue. It happens to me when I try to reproduce this example on my local machine using @mrblenny/react-flow-chart": "^0.0.13, node v10.20.1 and yarn v1.16.0.

troelsfr avatar Jun 19 '20 21:06 troelsfr