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

setState called after component has unmounted #7

Open
dchartfield opened this issue Feb 2, 2016 · 4 comments
Open

setState called after component has unmounted #7

dchartfield opened this issue Feb 2, 2016 · 4 comments

Comments

@dchartfield
Copy link

I came across the following Warning in my app

Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the StatefulDashboard component.

and on farther inspection it appears my Dashboard component, which had already unmounted was connected to a store that had been modified. The connectToStores#onChange was called, which in turn called this.setState(...), resulting in the above Warning message.

I'm thinking an isMounted() check would be applicable in the onChange method:

      onChange: function onChange() {
        if ( this.isMounted() ) {
          this.setState(Spec.getPropsFromStores(this.props, this.context));
        }
      },

Updating like so resolves the issue on my end. Let me know if you agree, and I can create a PR

@stowns
Copy link

stowns commented Apr 3, 2016

I have this exact issue. A component that is connected to a store (isLoggedIn) calls actions.logout() which in-turn causes a parent component to unmount the isLoggedIn component. It appears that after the isLoggedIn is unmounted it receives an update from the store.

@JonathanKolnik
Copy link

+1 I am also running into this repeatedly

@ashlux
Copy link

ashlux commented Sep 26, 2016

+1 - It's very annoying and clutters the console output too.

@vivekiyer114
Copy link

Any fixes for this issue ?

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