react-jsx-highcharts
Advanced tools
Comparing version 1.4.1 to 1.4.2
{ | ||
"name": "react-jsx-highcharts", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Highcharts charts built using React components", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-jsx-highcharts.min.js", |
import { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import addEventProps, { getNonEventHandlerProps } from '../../utils/events'; | ||
import getModifiedProps from '../../utils/getModifiedProps'; | ||
@@ -19,3 +20,4 @@ class Chart extends Component { | ||
onSelection: PropTypes.func, | ||
update: PropTypes.func | ||
update: PropTypes.func, // Provided by ChartProvider | ||
getChart: PropTypes.func // Provided by ChartProvider | ||
}; | ||
@@ -34,2 +36,8 @@ | ||
constructor (props) { | ||
super(props); | ||
this.updateChart = this.updateChart.bind(this); | ||
} | ||
componentDidMount () { | ||
@@ -39,7 +47,5 @@ const { type, children, update, getChart, ...rest } = this.props; | ||
const notEventProps = getNonEventHandlerProps(rest); | ||
update({ | ||
chart: { | ||
type, | ||
...notEventProps | ||
} | ||
this.updateChart({ | ||
type, | ||
...notEventProps | ||
}); | ||
@@ -50,2 +56,15 @@ | ||
componentDidUpdate (prevProps) { | ||
const modifiedProps = getModifiedProps(prevProps, this.props); | ||
if (modifiedProps !== false) { | ||
this.updateChart(modifiedProps); | ||
} | ||
} | ||
updateChart (config) { | ||
this.props.update({ | ||
chart: config | ||
}, true); | ||
} | ||
render () { | ||
@@ -52,0 +71,0 @@ return null; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
539764
9830