question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setState can only update a mounted or mounting component warning

See original GitHub issue

Hi,

I’m trying to use this boilerplate with react (react branch) but when I try to set a state (this.setState) I keep getting this warning in the console:

warning.js?8a56:33 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 ReactComponent component.

The component isn’t unmounted, even with the easiest state change I get the same warning. Maybe this has something to do with the fact that it’s a chrome extension?

I hope someone can help me out here. Thanks in advance,

Giel.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
samuelsimoescommented, Oct 14, 2017

I was investigating this and I found something curious. The problem that you related in fact exists and it is related to the React Hot Reload, I don’t know exactly what is happening, but if you include the es2015 babel preset, everything works fine. Later on, I’ll update the React Hot Reload to see if it’s fixed.

5reactions
occultcommented, Feb 5, 2018

I also ran into this problem. If you need a quick fix, remove the binding in the constructor and bind it when you call it in the JSX part.

Do this: <form className='uk-grid-small' data-uk-grid onSubmit={this.updateResults.bind(this)}>

Don’t do this: this.updateResults = this.updateResults.bind(this)

Read more comments on GitHub >

github_iconTop Results From Across the Web

setState(...): Can only update a mounted or ... - Stack Overflow
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component.
Read more >
Warning: setState(...): Can only update a mounted or ... - GitHub
"Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a...
Read more >
React: Stop checking if your component is mounted - Medium
This article will provide solutions to the “Can't perform a React state update on an unmounted component” warning and why a call to...
Read more >
Prevent React setState on unmounted component - Martin Belev
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted ...
Read more >
Untitled
It is clear that this.setState can only be called on a mounted or mounting component. A mildly confusing situation I encountered was a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found