Open SHASHANK9743 opened 4 years ago
Did you check if the answer from your API call does not return data with twice the same ID ?
@SHASHANK9743 I ran into a similar issue on one of my own projects, in which I was also fetching data to add to the graph.
I discovered that this error is thrown when a node with an image property has a nuill value before being pushed to the nodes array. This happens even if all the nodes actually have unique IDs. I got around this by setting the value to an empty string instead of null. Empty strings seem to work just fine, and result in a blank node when drawn. Not sure if this is the issue for you, but I suggest double checking this.
Below is an example object that I push onto the nodes array of my graph. If artistImage
is null, the error you encountered is thrown. Again, I got around this by making sure artistImage
is an empty string if there's no associated image url.
const artistNode = { id: artist.id, label: artist.name, title: artist.name, shape: "circularImage", image: artistImage };
Hi, I am serving the data directly from an API in the specified format. I am rendering the graph inside a Class component. the initial state is as follows graph = {nodes : [], edges : []}
I am fetching the data inside Component Did Mount and then setting the state of the Graph.
However while rendering it always gives me the error Node with ID "some id" already exist. Please help I have been struggling with this for a long time now.