Skip to content

Commit

Permalink
Merge pull request #328 from anajavi/react16
Browse files Browse the repository at this point in the history
Add React 16 peer dependency and fix warning about defaultProps
  • Loading branch information
kirjs authored Oct 11, 2017
2 parents cc0a011 + 9a5dd28 commit a9c5aac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"url": "https://github.com/kirjs/react-highcharts"
},
"peerDependencies": {
"react": "~0.14 || ^15.0.0",
"react-dom": "~0.14 || ^15.0.0"
"react": "~0.14 || ^15.0.0 || ^16.0.0",
"react-dom": "~0.14 || ^15.0.0 || ^16.0.0"
},
"bugs": "https://github.com/kirjs/react-highcharts/issues",
"keywords": [
Expand Down
17 changes: 10 additions & 7 deletions src/chartsFactory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ module.exports = function (chartType, Highcharts){
callback: PropTypes.func,
domProps: PropTypes.object
},

defaultProps: {
callback: () =>{},
domProps: {}
getDefaultProps: function() {
return {
callback: () =>{},
domProps: {}
};
},
setChartRef: function(chartRef) {
this.chartRef = chartRef;
},

renderChart: function (config){
if (!config) {
throw new Error('Config must be specified for the ' + displayName + ' component');
Expand All @@ -30,7 +33,7 @@ module.exports = function (chartType, Highcharts){
...config,
chart: {
...chartConfig,
renderTo: this.refs.chart
renderTo: this.chartRef
}
}, this.props.callback);

Expand Down Expand Up @@ -65,7 +68,7 @@ module.exports = function (chartType, Highcharts){
},

render: function (){
return <div ref="chart" {...this.props.domProps} />;
return <div ref={this.setChartRef} {...this.props.domProps} />;
}
});

Expand Down

0 comments on commit a9c5aac

Please sign in to comment.