Updating DiagramWidget leads to loss of event listeners
Good day!
If I am using approach from demos, creating DiagramEngine on every render, I'm facing following issue:
After re-rendering of the component which includes <DiagramWidget> inside, I can't control diagram anymore - e.g. calling diagramEngine.repaintCanvas() will have no effect.
It happens because of React component lifecycle. Since DiagramWidget adds listener in componentDidMount (source) - it won't add listener again if parent component will be re-rendered (because componentDidMount is part of mounting lifecycle methods called only first time, second time component will go through updating lifecycle methods). So it leads to the situation where DiagramWidgets listens events from outdated diagramEngine.
Now I have workaround where I use diagram widget in a following way:
<DiagramWidget diagramEngine={engine} key={engine.id} />
This forces react to create new widget for every new engine.
But also I think it will be good to handle componentWillReceiveProps in widget.
WDYT?
P.S: I'll create a PR