onModelChange is called after the first time ReactDiagram rendered

Hi Walter, I’m using ReactDiagram in this way:
<ReactDiagram
ref={refDiagram}
divClassName=‘diagram-waterfall’
initDiagram={initDiagram(onNodeClick, language, makeUniqueKeyFunction, makeUniqueLinkKeyFunction)}
nodeDataArray={toJS(nodeDataArray)}
linkDataArray={toJS(linkDataArray)}
onModelChange={onModelChange}
skipsDiagramUpdate={false}
/>

I’m having a loop of rendering this ReactDiagram and the update on diagramModel caused by
onModelChange.
I am wondering why the onModelChange callback will be called at the first time. Shouldn’t it be called when a user make any changes to the diagram but not the first time?

This is a change we just introduced with the most recent version of gojs-react, as seen in the changelog. We did it so that any side effects that may take place during initialization will call the onModelChange callback such that React state can be updated if necessary.

As noted in a few places, you should make sure your onModelChange callback is setting skipsDiagramUpdate to true.

Thank you very much, jhardy, your info help me fix my issue. I hadn’t use a fixed version of gojs-react and it’s updated to 1.0.7 and this version won’t work in my code because we are not expect the ‘onModelChange’ being called at the first time.