make frontend more resilient to a broken graph

This commit is contained in:
Tao Bror Bojlén 2019-02-20 21:27:47 +00:00
parent dfaf15fb51
commit f4044a4cd7
No known key found for this signature in database
GPG Key ID: C6EC7AAB905F9E6F
1 changed files with 6 additions and 3 deletions

View File

@ -64,9 +64,12 @@ class GraphImpl extends React.Component {
}
componentDidUpdate() {
const sigma = this.sigmaComponent.current.sigma;
sigma.graph.nodes().map(this.colorNodes);
sigma.refresh();
const sigma = this.sigmaComponent && this.sigmaComponent.current.sigma;
// Check if sigma exists s.t. nothing breaks if the graph didn't load (for whatever reason)
if (sigma) {
sigma.graph.nodes().map(this.colorNodes);
sigma.refresh();
}
}
onClickNode = (e) => {