From f4044a4cd74d63930185cb7bc05cb71fab41ea03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bror=20Bojl=C3=A9n?= Date: Wed, 20 Feb 2019 21:27:47 +0000 Subject: [PATCH] make frontend more resilient to a broken graph --- frontend/src/components/Graph.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Graph.jsx b/frontend/src/components/Graph.jsx index ba26e71..ad6659e 100644 --- a/frontend/src/components/Graph.jsx +++ b/frontend/src/components/Graph.jsx @@ -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) => {