Skip to content

Commit

Permalink
fix(react): handle data updates from state, and fix errors with width…
Browse files Browse the repository at this point in the history
…/height prop
  • Loading branch information
theiliad committed Jun 25, 2019
1 parent 01b30bf commit a00294f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/react/src/base-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit a00294f

Please sign in to comment.