Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered two children with same key #104

Open
alexkalinins opened this issue Dec 24, 2020 · 9 comments
Open

Encountered two children with same key #104

alexkalinins opened this issue Dec 24, 2020 · 9 comments

Comments

@alexkalinins
Copy link

Hello. First of all, very nice project! After following the demonstrations in the documentation in JavaScript, I decided to try using the library with TypeScript. In my project, it is possible to add nodes with a button. We implement the TS types in our own object (CustomNode and CustomSchema that holds CustomNode instead of Node). We also use a custom renderer to display the nodes.

The our Node.id value is generated with uuid to make sure it is unique. The Port.id value is based on the same uuid, like '<node.id>-output-1'. The function that is triggered when button is pressed to make a new node makes a new node object instance and adds it to schema using addNode() method that we get from useSchema().

When we make a first node with button, nothing bad happens, we can drag it around and it is still fine. When we add a second node, immediately we get this error:

image

After adding the second node, dragging any node around or trying to link them repeats the same error continuously (complaining about the key of the second node). The links do form though and the function of our program is unaffected, only slows down performance significantly. The order of creation also does not matter; the first one works fine.

I tried adding a uuid key to the outer-most div in our custom renderer, but that does not fix it (the screenshot is without the uuid in div). Thank you for your help.

@andriy-kdp
Copy link

andriy-kdp commented Apr 30, 2021

@alexkalinins hello, are you solved this problem?

@Belashab
Copy link

@andriy-kdp @alexkalinins I don't know if issue is still relevant for you but it looks like I have found a way to fix this.

All you need is to change "NodesCanvas" to "NodesCanvas$1" in lines 7 and 89 in node_modules\beautiful-react-diagrams\esm\Diagram\Diagram.js

@adamsch
Copy link

adamsch commented Jun 11, 2021

@Belashab Are you sure this fixes it? I just tried and it doesn't seem to work. I'm having the same issue

@danlobo
Copy link

danlobo commented Dec 6, 2021

For some reason, addNode internal dispatch is called twice, so the schema ends with two identical nodes.

@serhii-baraniuk
Copy link

Have the same issue by using NextJs

@logemann
Copy link

addNode is definitely broken since dispatching seems wrong. Added 3 nodes got 5 at the end with duplicate ID errors.

@zihanxu3
Copy link

Same here - has anyone found a solution yet? Please kindly advise, thanks!

@mtan11
Copy link

mtan11 commented Nov 2, 2022

I have the same issue. Does anyone solve this problem?

@xsudiptaster
Copy link

Having the same Issue.. AddNode is adding two nodes at once..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants