projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.58k stars 1.17k forks source link

What is the Best way to removeNode programatically? #827

Open kapilkumawat86 opened 3 years ago

kapilkumawat86 commented 3 years ago

I have tried the below ways, but the model is not removing the node.

model.removeNode(node)

const node = model.getNodeFromId(id)
    if (node) {
      const ports = node.getPorts()
      for (const portKey in ports) {
        const port = ports[portKey]
        const links = port.getLinks()
        for (const keyLink in links) {
          const link = links[keyLink]
          link.remove()
        }
        port.remove()
      }
      node.remove()
    }
renato-bohler commented 3 years ago

What works for me is:

node.remove();
engine.repaintCanvas();
kapilkumawat86 commented 3 years ago

I tried this still same issue.