Skip to content

Commit a9c5aac

Browse files
authored
Merge pull request #328 from anajavi/react16
Add React 16 peer dependency and fix warning about defaultProps
2 parents cc0a011 + 9a5dd28 commit a9c5aac

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"url": "https://github.com/kirjs/react-highcharts"
2525
},
2626
"peerDependencies": {
27-
"react": "~0.14 || ^15.0.0",
28-
"react-dom": "~0.14 || ^15.0.0"
27+
"react": "~0.14 || ^15.0.0 || ^16.0.0",
28+
"react-dom": "~0.14 || ^15.0.0 || ^16.0.0"
2929
},
3030
"bugs": "https://github.com/kirjs/react-highcharts/issues",
3131
"keywords": [

src/chartsFactory.jsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ module.exports = function (chartType, Highcharts){
1515
callback: PropTypes.func,
1616
domProps: PropTypes.object
1717
},
18-
19-
defaultProps: {
20-
callback: () =>{},
21-
domProps: {}
18+
getDefaultProps: function() {
19+
return {
20+
callback: () =>{},
21+
domProps: {}
22+
};
23+
},
24+
setChartRef: function(chartRef) {
25+
this.chartRef = chartRef;
2226
},
23-
2427
renderChart: function (config){
2528
if (!config) {
2629
throw new Error('Config must be specified for the ' + displayName + ' component');
@@ -30,7 +33,7 @@ module.exports = function (chartType, Highcharts){
3033
...config,
3134
chart: {
3235
...chartConfig,
33-
renderTo: this.refs.chart
36+
renderTo: this.chartRef
3437
}
3538
}, this.props.callback);
3639

@@ -65,7 +68,7 @@ module.exports = function (chartType, Highcharts){
6568
},
6669

6770
render: function (){
68-
return <div ref="chart" {...this.props.domProps} />;
71+
return <div ref={this.setChartRef} {...this.props.domProps} />;
6972
}
7073
});
7174

0 commit comments

Comments
 (0)