react-google-charts
react-google-charts copied to clipboard
onResize still exists after Chart is unmounted
Version
react-google-charts 1.4.2 react v15.4.2
Expected behaviour
After component with
Actual behaviour
For now, it seems that this is not the case. When I unmount view with Chart, and try to resize window, I am getting next error:
at Object.gvjs_T.Kc (jsapi_compiled_default_module.js:103)
at e.updateDataTable (Chart.js:187)
at e.drawChart (Chart.js:214)
at e.onResize (Chart.js:119)
Steps to reproduce
Just create two pages, one with Chart, another without. Open page with Chart, then (probably with router) open another one. Try to resize window. You should get an error.
Sample case
https://jsfiddle.net/f8zpr8uc/4/
FYI, this problem still seem to exist. Temporary fix that works for us:
componentWillUnmount () {
if (this.chartRef) {
window.removeEventListener('resize', this.chartRef.onResize);
}
}