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

2.0 triggers resize when component unmount #27

Closed
rockmandash opened this issue Feb 26, 2018 · 12 comments
Closed

2.0 triggers resize when component unmount #27

rockmandash opened this issue Feb 26, 2018 · 12 comments

Comments

@rockmandash
Copy link

2.0 triggers resize when component unmount
So the resize remain, if you modify props in -onResize, things will break!

@maslianok
Copy link
Owner

Can you provide a code snippet so I can reproduce this issue?

@rockmandash
Copy link
Author

rockmandash commented Feb 26, 2018

I think I'm wrong.

@cephirothdy2j
Copy link

I'm seeing this issue as well. Simply put, the resize method fires when the component unmounts, which causes the classic React error:

Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.

@lh0x00
Copy link
Contributor

lh0x00 commented Mar 27, 2018

@cephirothdy2j hi, please tell me a example code, maybe can I help you ^^

@matsilva
Copy link
Contributor

I ran into the same issue and could resolve by calling unobserve in componentWillUnmount.
image

Before I did this, I almost did something similar to what the folks behind recharts did https://github.com/recharts/recharts/blob/master/src/component/ResponsiveContainer.js#L71

Notice they are setting a mounted flag to fix this issue.

@cephirothdy2j
Copy link

Setting the "mounted" flag is what I ended up doing as well.

@matsilva
Copy link
Contributor

#32 @cephirothdy2j can you build and test in your project to see if this works?

@cephirothdy2j
Copy link

Yes, that PR appears to resolve the issue. 👍

@matsilva
Copy link
Contributor

Yes, that PR appears to resolve the issue. 👍

Thanks for checking it out.

@maslianok maslianok reopened this Mar 28, 2018
@maslianok
Copy link
Owner

Thanks to everyone for your involvement!

@matsilva Huge thanks for the PR! :)

@maslianok
Copy link
Owner

[email protected] published to npm with this fix!

@matsilva
Copy link
Contributor

[email protected] published to npm with this fix!

Awesome! Thanks a lot.

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

5 participants