Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The handler onResize was still triggered after a component has been unmount #7

Open
xile611 opened this issue Aug 18, 2016 · 9 comments

Comments

@xile611
Copy link

xile611 commented Aug 18, 2016

@okonet
I find that when a ContainerDimensions element has been mount and unmount quickly an error is thrown.
image

This error happens because the ready event of scroll is trigger although the listener has been removed.
2016-08-18 8 31 55

Do you have any idea to fix this problem ? Thank you !

@okonet
Copy link
Owner

okonet commented Aug 18, 2016

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?

@xile611
Copy link
Author

xile611 commented Aug 19, 2016

@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:

image

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!

@okonet
Copy link
Owner

okonet commented Aug 19, 2016

Can you create a repo with this error easily reproducible?

@xile611
Copy link
Author

xile611 commented Aug 19, 2016

@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.

@okonet
Copy link
Owner

okonet commented Aug 19, 2016

👌 Submit a PR and don't forget tests!

@tomsue
Copy link

tomsue commented Sep 30, 2016

image

just need add the _isMounted to validate......I already test .....wish to handle

@tomsue
Copy link

tomsue commented Sep 30, 2016

wish fix as soon as.....Recharts use this package and get some effect .

@okonet
Copy link
Owner

okonet commented Sep 30, 2016

@tomsue Can you submit a PR. Please also add tests for it. Thanks!

@xile611
Copy link
Author

xile611 commented Oct 11, 2016

@tomsue It's a good idea to add the variable isMounted. Maybe you can submit a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants