Skip to content

Commit c1f7cfe

Browse files
author
Nicolas ERNY
authored
Fix "cannot read property startTransaction of undefined" (#114)
1 parent 2d352e2 commit c1f7cfe

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-gojs",
3-
"version": "4.6.0",
3+
"version": "4.6.1",
44
"description": "GoJS React integration",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/GojsDiagram.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,18 @@ class GojsDiagram<N extends BaseNodeModel, L extends LinkModel> extends React.Pu
9292
}
9393

9494
componentDidUpdate() {
95-
this.myDiagram.startTransaction();
96-
this.applyAddRemoveLinksFromModel();
97-
this.applyAddRemoveNodesFromModel();
98-
this.applyUpdatesFromModel();
99-
if (this.props.updateDiagramProps) {
100-
this.props.updateDiagramProps(this.myDiagram);
95+
if (this.myDiagram) {
96+
this.myDiagram.startTransaction();
97+
this.applyAddRemoveLinksFromModel();
98+
this.applyAddRemoveNodesFromModel();
99+
this.applyUpdatesFromModel();
100+
if (this.props.updateDiagramProps) {
101+
this.props.updateDiagramProps(this.myDiagram);
102+
}
103+
this.myDiagram.updateAllRelationshipsFromData();
104+
this.myDiagram.updateAllTargetBindings();
105+
this.myDiagram.commitTransaction('updated');
101106
}
102-
this.myDiagram.updateAllRelationshipsFromData();
103-
this.myDiagram.updateAllTargetBindings();
104-
this.myDiagram.commitTransaction('updated');
105107
}
106108
init() {
107109
const { createDiagram, diagramId, onModelChange, defaultSelectedNode } = this.props;

0 commit comments

Comments
 (0)