From 3d55ae6b9ce1d207be0dbeec8547e0b26b92e0c2 Mon Sep 17 00:00:00 2001 From: Andre Mas Date: Tue, 18 Jul 2017 16:51:58 -0400 Subject: [PATCH 1/2] Fixes issue #10, whereby an update happens before a mount --- src/ReactBubbleChart.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ReactBubbleChart.js b/src/ReactBubbleChart.js index d14b676..fa62574 100644 --- a/src/ReactBubbleChart.js +++ b/src/ReactBubbleChart.js @@ -152,6 +152,10 @@ class ReactBubbleChart extends React.Component { /** When we update, update our friend, the bubble chart */ componentDidUpdate() { + // Apparently updates can happen before a mount, so deal with this scenario + if (!this.bubbleChart) { + this.bubbleChart = new ReactBubbleChartD3(this.getDOMNode(), this.getChartState()); + } this.bubbleChart.update(this.getDOMNode(), this.getChartState()); } From ad73a12c5af6fa801434b423b22d053f84a9f141 Mon Sep 17 00:00:00 2001 From: Andre-John Mas Date: Tue, 18 Jul 2017 18:06:11 -0400 Subject: [PATCH 2/2] logic change in componentDidUpdate --- src/ReactBubbleChart.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ReactBubbleChart.js b/src/ReactBubbleChart.js index fa62574..5a9162d 100644 --- a/src/ReactBubbleChart.js +++ b/src/ReactBubbleChart.js @@ -153,10 +153,9 @@ class ReactBubbleChart extends React.Component { /** When we update, update our friend, the bubble chart */ componentDidUpdate() { // Apparently updates can happen before a mount, so deal with this scenario - if (!this.bubbleChart) { - this.bubbleChart = new ReactBubbleChartD3(this.getDOMNode(), this.getChartState()); + if (this.bubbleChart) { + this.bubbleChart.update(this.getDOMNode(), this.getChartState()); } - this.bubbleChart.update(this.getDOMNode(), this.getChartState()); } /** Define what props get passed down to the d3 chart */