Coder Social home page Coder Social logo

Comments (6)

flatplate avatar flatplate commented on July 30, 2024 2

I have the same problem. I have found that supplying a new key every time you update the data works. I update the graph like this:

let [graph, setGraph] = useState({ nodes: [], edges: [], rand: "" });
...
setGraph({
    nodes: nodes,
    edges: edges,
    rand: Math.random().toString(),
});

And I use the Graph element like this:

<Graph
    key={graph.rand}
    ...
/>

Hope this helps until we can find a better solution.

from vis-react.

anishmprasad avatar anishmprasad commented on July 30, 2024

please share api_res object

from vis-react.

oculardexterity avatar oculardexterity commented on July 30, 2024

I have same issue, I think.

Graph is in react state:

const [graph, setGraph] = useState({
    nodes: [
      { id: 1, label: "Node 1" },
      { id: 2, label: "Node 2" },
      { id: 3, label: "Node 3" },
      { id: 4, label: "Node 4" },
      { id: 5, label: "Node 5" },
    ],
    edges: [
      { from: 1, to: 2},
      { from: 1, to: 3 },
      { from: 2, to: 4 },
      { from: 2, to: 5 },
    ],
  });

But when I call:

   setGraph({
      nodes: [...graph.nodes, { id: "6", label: 'Node 6' }],
      edges: [...graph.edges],
    });

I get the error Uncaught Error: Cannot add item: item with id 6 already exists

I guess this is the same error as #8: the add node function is being called twice for some reason, thus producing error

from vis-react.

danwt avatar danwt commented on July 30, 2024

Same issue here

from vis-react.

leonardorodd avatar leonardorodd commented on July 30, 2024

Same

from vis-react.

j6k4m8 avatar j6k4m8 commented on July 30, 2024

Hitting the same problem here. For some more diagnostic color, I randomly generated a string in render() and prepend all node IDs with that string; this is calling twice in the same render cycle (i.e. the issue is not calling render twice etc).

from vis-react.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.