Unverified Commit 348c6284 authored by afc163's avatar afc163

Fix setState after unmount

parent 4a89fa12
......@@ -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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment