-
Notifications
You must be signed in to change notification settings - Fork 801
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 #446
Comments
This error is usually caused by #313, but it looks like you have the |
Solved didierfranc/redux-react-starter@e66ab1f It seems that render should be equal here
and
I did not want to have
at the root of my project, if you have better solution I'll take it ! |
@didierfranc I tried this and although the error is gone, hot reloading is not working. Did you experience this at all? |
I had this issue when trying to switch from
|
@penx thanks! It solved the problem in my case. 😄 |
Just leaving a note for fellow Typescript googlers. A TS equivalent of @penx's babel solution would be:
|
The root cause - arrow functions. You have to avoid them yet. |
@penx thanks! you saved my week! |
Everyone - version 4 solves this. Update today. |
@vkosovskikh, gonna to fix this in next release. |
@theKashey yes but this is very very annoying. In a big application it is a ton of warnings. |
One warning for a one component 🤷♂️ |
@vkosovskikh - could you try the last beta version? |
@theKashey had the same issue just now with version 4.0.0-beta.21, updating for 4.0.0-beta.22 solved the problem |
@theKashey seems solved, ty |
I've been trying to research this for a while now and I'm still getting this warning. Is it just me? https://github.com/Cottin/some-boilerplates/tree/master/react-hot-warning |
@Cottin - here is an explanation class Hello extends React.Component {
constructor(props) {
super(props)
this.state = {name: '...'};
this.getNameAndSet = this.getNameAndSet.bind(this)
this.getNameAndSet() <-- will be executed on Class(Component) creation
}
getNameAndSet() {
console.log(this)
setTimeout((() => this.setState({name: 'Worrrld'})), 100) <-- will _always_ be fired
} During update RHL trying to undertand wich changes were made, and creating an old and a new class to compare them. You shall not trigger state change mechanics in the constructor. Move this logic to componentDidMount. |
@theKashey Thanks a lot for explanation! Works great with |
Description
Any idea why I'm getting this when hot reloading happened ?
Expected behavior
To not have this error
Actual behavior
Everything seems fine but console log errors like that 👆
Environment
React Hot Loader version: 3.0.0-beta.6
Run these commands in the project folder and fill in their results:
Reproducible Demo
Run the project, editing some code from this https://github.com/didierfranc/redux-react-starter and error appear on stateful components.
The text was updated successfully, but these errors were encountered: