jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.64k stars 722 forks source link

TypeError: Cannot read properties of undefined (reading 'data') #259

Closed LA1709 closed 2 years ago

LA1709 commented 2 years ago

I am working in react with drawflow, I have created a ref to the drawflow editor. On running the method removeNodeId on the editor.current, it gives me the following error - TypeError: Cannot read properties of undefined (reading 'data'). Note: I can run all other methods like getNodeId and they work as intended.

image

Here it can be seen, I log the node in the console before attempting to remove it and then it throws and error when the removeNodeId method is called on it.

jerosoler commented 2 years ago

Hi @LA1709

How are you deleting the node?

removeNodeId(id);

The id is "node-id" example: "node-5"

removeNodeId(`node-${id}`);

Are you doing it the right way?

LA1709 commented 2 years ago

No! Thank you so much! I was just passing the id (for example: 5) to the function.