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

Warning: setState(...): Can only update a mounted or mounting component. #71

Closed
pierrecholhot opened this issue Dec 22, 2015 · 6 comments

Comments

@pierrecholhot
Copy link

When the Geosuggest input is in focus and the react route changes, the following warning pops in the console:

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 Geosuggest component.

Then it points to this part:

/**
 * When the input loses focused
 */
hideSuggests: function hideSuggests() {
  this.props.onBlur();
  setTimeout((function () {
    this.setState({ isSuggestsHidden: true });
  }).bind(this), 100);
},

Not sure if I am supposed to destroy the component somehow in my componentWillUnmount() ?


geo


    "history": "~1.13.x",
    "react": "^0.14.3",
    "react-dom": "^0.14.3",
    "react-geosuggest": "^1.13.0",
    "react-router": "^1.0.2",
@ro-ka
Copy link
Contributor

ro-ka commented Jan 4, 2016

I suppose we need a check in that setTimeout whether it is still mounted or not.

@ro-ka ro-ka closed this as completed in 67972d0 Jan 4, 2016
@romseguy
Copy link
Contributor

I'm still getting that warning, it looks like we can't call this.setState in componentWillUnmount here https://github.com/ubilabs/react-geosuggest/blob/master/src/Geosuggest.jsx#L90

Related issue facebook/react#2787 ; this comment particularly facebook/react#2787 (comment)

@ro-ka
Copy link
Contributor

ro-ka commented Feb 5, 2016

Will take a look.

@ro-ka ro-ka reopened this Feb 5, 2016
@amitava82
Copy link

I just received same error on route change scenario.

@ro-ka ro-ka closed this as completed in b347e9a Mar 11, 2016
@ro-ka ro-ka mentioned this issue Mar 11, 2016
@ro-ka
Copy link
Contributor

ro-ka commented Mar 11, 2016

Released in 1.19.0.

@sergeyt
Copy link

sergeyt commented Aug 22, 2016

This warning can still output in callback of autocomplete service, now at line 190.

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