-
Notifications
You must be signed in to change notification settings - Fork 730
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
Can't call setState (or forceUpdate) on an unmounted component. #336
Comments
so https://github.com/hshoff/vx/blob/master/packages/vx-responsive/src/components/ParentSize.js#L18 was just merged in yesterday but hasn't been published yet (#335). Just a few question to help get this fixed: Which version of |
Oops, i was just browsing the code looking for what could've caused it, but setState in a raf can be troublesome when a transitiongroup wraps it, adding an this.mounted flag will prevent this warning from ever occuring. My dependencies are quite outdated atm: "@vx/responsive": "0.0.158" This version calls setState in a resizeObserver cb. |
edit: actually shouldn't the |
v0.0.172 is published: https://github.com/hshoff/vx/releases/tag/v0.0.172 @drcmda would you mind updating your |
Upgrading
Update: The upgrade does in fact work- we had another component that was causing the same error. |
@JacquiManzi thanks for following up @JacquiManzi! Going to close this issue as it appears resolved. @drcmda happy to re-open if you find it did not fix for your use case. |
@hshoff thanks! it looks like it's fixed! |
Full message:
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in ParentSize (created by ItemList)
This seems to happen because of https://github.com/hshoff/vx/blob/master/packages/vx-responsive/src/components/ParentSize.js#L18 The component lives inside a transition that removes it conditionally, the raf probably comes a single frame too late.
I think the best way around it would be to track mounted state in componentDidMount/componentWillUnmount: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html , and then checking for it before doing setState.
The text was updated successfully, but these errors were encountered: