setState can only update a mounted or mounting component warning
See original GitHub issueHi,
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:
- Created 6 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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)