Any idea why I'm getting this when hot reloading happened ?

To not have this error
Everything seems fine but console log errors like that 👆
React Hot Loader version: 3.0.0-beta.6
Run these commands in the project folder and fill in their results:
yarn && yarn start
Run the project, editing some code from this https://github.com/didierfranc/redux-react-starter and error appear on stateful components.
This error is usually caused by #313, but it looks like you have the es2015 preset. I'll try running your project later today and see what's going on.
Solved https://github.com/didierfranc/redux-react-starter/commit/e66ab1f3e5be6558f537632529c3e7a5b054b813
It seems that render should be equal here
render()
and
module.hot.accept('../src', render)
I did not want to have <AppContainer /> in my prod bundle so I needed to split that, the solution is :
if (!module.hot) render(<Root />, document.querySelector('react'))
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 babel-preset-es2015 to babel-preset-env. Adding transform-es2015-classes to the included transforms resolved it for me:
presets: [
['env', {
targets: {
chrome: 60
},
include: ['transform-es2015-classes']
}],
'stage-1',
'react'
],
plugins: ['react-hot-loader/babel']
@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:
// tsconfig.json
{
"compilerOptions": {
"target": "es5"
}
}
The root cause - arrow functions. You have to avoid them yet.
@penx thanks! you saved my week!
Everyone - version 4 solves this. Update today.
Same problem with version 4.0.0-beta.18 of react-hot-loader. Error occurs when I save some changes on component and change route by clicking a button. Any help?
.babelrc:
```
presets: [
['es2015', { modules: false }],
'stage-0',
'react'
],
plugins: [
'react-hot-loader/babel'
]
````

@vkosovskikh, gonna to fix this in next release.
Keep in mind - this is not an errors, just a warning.
@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
If somebody wants to reproduce, I made a minimal example above.
@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.
Creating, and throwing away, not adding to the tree.
You shall not trigger state change mechanics in the constructor. Move this logic to componentDidMount.
@theKashey Thanks a lot for explanation! Works great with componentDidMount!
Most helpful comment
I had this issue when trying to switch from
babel-preset-es2015tobabel-preset-env. Addingtransform-es2015-classesto the included transforms resolved it for me: