projectstorm / react-diagrams

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

Canvas crashes when browser DOM updates (TypeError: Cannot read properties of null (reading 'offsetWidth')) #921

Open louis-md opened 2 years ago

louis-md commented 2 years ago

Hello,

First off congrats for this great project!

I encountered an issue when trying to use react-diagrams while the browser DOM updates. Let's consider a project such as:

Using react-diagrams at version 6.7.0, and even with the simplest diagram possilble:

const Diagram = () => {
  const engine = createEngine()
  engine.setModel(new DiagramModel())
  return <CanvasWidget engine={engine} />
}

it will trigger:

Capture d’écran 2022-02-17 à 19 33 13

When changing "Page 2" so that it imports component A directly (instead of component B), the problem does not occur.

No problem when mounting, unmounting, remounting or updating with react's shadow DOM. The error seems to occur when the browser DOM (not React's shadow DOM) updates, e.g. when there is a change in react's component tree.

Thanks in advance for the help.

jpros commented 9 months ago

Any updates on this one?

jpros commented 9 months ago

This one should be closed by this: https://github.com/projectstorm/react-diagrams/issues/671