react-google-charts icon indicating copy to clipboard operation
react-google-charts copied to clipboard

onResize still exists after Chart is unmounted

Open dmart28 opened this issue 9 years ago • 1 comments

Version

react-google-charts 1.4.2 react v15.4.2

Expected behaviour

After component with is unmounted, is correctly unmounted as well.

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/

dmart28 avatar Feb 07 '17 04:02 dmart28

FYI, this problem still seem to exist. Temporary fix that works for us:

componentWillUnmount () {
  if (this.chartRef) {
    window.removeEventListener('resize', this.chartRef.onResize);
  }
}

gson88 avatar Jan 11 '18 09:01 gson88