diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js index 5f80d7477bba18a56a40f7cf966a832dd2f0b0ae..c6370ea3d0dcd13ada30e72913e70e4a230f4e31 100644 --- a/src/components/Charts/Pie/index.js +++ b/src/components/Charts/Pie/index.js @@ -41,6 +41,9 @@ class Pie extends Component { window.cancelAnimationFrame(this.requestRef); window.removeEventListener('resize', this.resize); this.resize.cancel(); + if (this.chartDom) { + this.resizeObserverInstance.unobserve(this.chartDom); + } } getG2Instance = chart => { @@ -94,7 +97,7 @@ class Pie extends Component { }; resizeObserver() { - const ro = new ResizeObserver(entries => { + this.resizeObserverInstance = new ResizeObserver(entries => { const { height } = entries[0].contentRect; this.setState(preState => { if (preState.height !== height) { @@ -106,7 +109,7 @@ class Pie extends Component { }); }); if (this.chartDom) { - ro.observe(this.chartDom); + this.resizeObserverInstance.observe(this.chartDom); } }