Skip to content

Commit a00294f

Browse files
committed
fix(react): handle data updates from state, and fix errors with width/height prop
1 parent 01b30bf commit a00294f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: packages/react/src/base-chart.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@ export default class BaseChart extends React.Component {
1010
// Width prop is mandatory for the wrappers
1111
if (props.width) {
1212
this.options.width = props.width;
13-
} else {
13+
} else if (!this.options.width) {
1414
console.error("Missing `width` prop!");
1515
}
1616

1717
// Height prop is mandatory for the wrappers
1818
if (props.height) {
1919
this.options.height = props.height;
20-
} else {
20+
} else if (!this.options.height) {
2121
console.error("Missing `height` prop!");
2222
}
2323

2424
Object.assign(this, this.chart);
2525
}
26+
27+
componentDidUpdate(newProps) {
28+
const { data } = newProps;
29+
30+
this.chart.setData(data);
31+
}
2632
}

0 commit comments

Comments
 (0)