GoJS + React: handleModelChange

We have built a GoJS + React application, trying to follow your stateful React App aaproach

I had problems using your handleModelChange approach correctly, so I built my app using handleDiagramEvent.
This works fine, except for the situation where I add a new node (e.g. using ExternalObjectsDropped),
and then want to connect a link from the new node to one of the other nodes.
Then my list of nodes do not contain the new node I created and connecting the link fails.

I came to the conclusion that I probably have to use handleModelChange to handle addded nodes,
and I went back to trying your handleModelChange approach, and implemented handleModelChange as follows:

public handleModelChange(obj: go.IncrementalData) {
const insertedNodeKeys = obj.insertedNodeKeys;
const modifiedNodeData = obj.modifiedNodeData;
const removedNodeKeys = obj.removedNodeKeys;
const insertedLinkKeys = obj.insertedLinkKeys;
const modifiedLinkData = obj.modifiedLinkData;
const removedLinkKeys = obj.removedLinkKeys;
const modifiedModelData = obj.modelData;

console.log('145 insertedNodeKeys', obj.insertedNodeKeys);
console.log('146 modifiedNodeData', obj.modifiedNodeData);
console.log('147 removedNodeKeys', obj.removedNodeKeys);
console.log('148 insertedLinkKeys', obj.insertedLinkKeys);
console.log('149 modifiedLinkData', obj.modifiedLinkData);
console.log('150 removedLinkKeys', obj.removedLinkKeys);
console.log('151 modifiedModelData', obj.modifiedModelData);


The problem is that all the console.log prints out ‘undefined’. If I inspect obj,
I do not find insertedNodeKeys or any of the other variables.

So the question is: What do I do wrong?

Here’s a sample that demonstrates the behavior that I think you are asking for:

That doesn’t use React or Angular or any other framework, but why involve them when you don’t need to?