react-container-dimensions
react-container-dimensions copied to clipboard
The handler `onResize` was still triggered after a component has been unmount
@okonet
I find that when a ContainerDimensions element has been mount and unmount quickly an error is thrown.
This error happens because the ready event of scroll is trigger although the listener has been removed.
Do you have any idea to fix this problem ? Thank you !
Well, that's a warning, not an error, to begin with. I'm not sure how to solve this but I'm also not sure if this should be solved. Nothing bad is happening in this case. I could try set some flag that event listener is set and remove it on onUnmount. Do you want to submit a PR?
@okonet Something don't show because this warning! That's why I notice this warning. I think some events are still triggered although the listener has been removed.
componentWillUnmount() {
this.elementResizeDetector.removeListener(this.parentNode, this.onResize)
}
So I try to uninstall the resize detector, but some other error happens:
I'm not familiar with the element-resize-detector. It'll take me some time to find the solution. So I ask you for help!
Can you create a repo with this error easily reproducible?
@okonet
https://github.com/xile611/react-container-dimensions-demo
And you are right! The warning doesn't affect the running of my component. It's another problem! But I want to fix this warning because I'm worried about whether this will result in performance problems.
👌 Submit a PR and don't forget tests!
just need add the _isMounted to validate......I already test .....wish to handle
wish fix as soon as.....Recharts use this package and get some effect .
@tomsue Can you submit a PR. Please also add tests for it. Thanks!
@tomsue It's a good idea to add the variable isMounted
. Maybe you can submit a PR to fix this.