From a00294f9f09f893f5c02c680ea514c661c95a376 Mon Sep 17 00:00:00 2001 From: Eliad Moosavi Date: Tue, 25 Jun 2019 14:55:33 -0400 Subject: [PATCH] fix(react): handle data updates from state, and fix errors with width/height prop --- packages/react/src/base-chart.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react/src/base-chart.js b/packages/react/src/base-chart.js index 91d569936b..cc42104ec2 100644 --- a/packages/react/src/base-chart.js +++ b/packages/react/src/base-chart.js @@ -10,17 +10,23 @@ export default class BaseChart extends React.Component { // Width prop is mandatory for the wrappers if (props.width) { this.options.width = props.width; - } else { + } else if (!this.options.width) { console.error("Missing `width` prop!"); } // Height prop is mandatory for the wrappers if (props.height) { this.options.height = props.height; - } else { + } else if (!this.options.height) { console.error("Missing `height` prop!"); } Object.assign(this, this.chart); } + + componentDidUpdate(newProps) { + const { data } = newProps; + + this.chart.setData(data); + } }