I'm getting that error message even though RHL seems to be working flawlessly. I've set
webpack-dev-server --mode development --hot but same results. Also added to the plugins:
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
}),
index.js
import React from 'react';
import { AppContainer } from 'react-hot-loader';
import { render } from 'react-dom';
import App from './src/app/containers/App';
render(
<AppContainer>
<App />
</AppContainer>,
document.getElementById('app'),
);
if (module.hot) {
module.hot.accept('./src/app/containers/App', () => {
// eslint-disable-next-line global-require
const NextRoot = require('./src/app/containers/App').default;
render(
<AppContainer>
<NextRoot />
</AppContainer>,
document.getElementById('app'),
);
});
}

I tried using the hot api, but RHL DOES NOT work with the following setup (it always provokes rull re-rendering of the site):
App.js
import { hot } from 'react-hot-loader';
import React from 'react';
...
export default hot(module)(App); // electron complains about using hot(App)
So that's why i'm using the _(old)_ index.js approach.
This is the repo i'm working on: https://github.com/nahuelarjonadev/kafka-lens/tree/react-hot-loader. Branch react-hot-loader.
Running yarn followed by yarn dev should be enough to try it.
Everything is working as expected, no error message is shown, the development branch of RHL is used.
I added some logs in a file node_module/react-hot-loader/index.js, then I found some interesting, !module.hot is true.

but in fileapp/index.tsx, module.hot is a object.

I used this template electron-react-boilerplate
I fixed this problem by moving react-hot-reload from dependencies to devDependencies. Thanks @bakaoh
Sounds like some electron magic.
So here's what was happening in my particular case:
I was using webpack functionality to include many of the dependencies as dll (so they wouldn't be recompiled each time you want to run webpack). It turned out that due to some misconfig, RHL was being compiled twice (one patched, the other not).
The one from the error msg was indeed not working, but the other one was (thus confusing me to be an inaccurate error msg).
So here's what was happening in my particular case:
I was using webpack functionality to include many of the dependencies as dll (so they wouldn't be recompiled each time you want to run webpack). It turned out that due to some misconfig, RHL was being compiled twice (one patched, the other not).
The one from the error msg was indeed not working, but the other one was (thus confusing me to be an inaccurate error msg).
@nahuelarjonadev can you describe what was wrong in particular? Thank you.
@sitnarf I'm out of town, give me a few days and I'll give you more detail
UPDATE: I've been swamped by other things. What was happening is that I had to patch RHL to enable its functionality. The library needs to be loaded by either babel, webpack or some entity that does corresponding checks to determine if the environment is production or not. According to the result of these checks, some patching needs to be done to the module.
Because I had included RHL as a dll dependency (to save dev environment startup time), there was an unpatched version being loaded by webpack. Then, babel was loading its own version of RHL, this one being patched correctly. Excluding RHL from the dll list stopped webpack from loading this unpatched version, leaving only the one loaded by babel (the working one).
I hope this is clear enough @sitnarf . I wanted to give you a small demo, but I just don't have the time right now
added
entry: ['react-hot-loader/patch', 'webpack-hot-middleware/client', './src']
Please refer https://gaearon.github.io/react-hot-loader/getstarted/
Most helpful comment
I added some logs in a file
node_module/react-hot-loader/index.js, then I found some interesting,!module.hotis true.but in file

app/index.tsx,module.hotis a object.I used this template electron-react-boilerplate
I fixed this problem by moving
react-hot-reloadfrom dependencies to devDependencies. Thanks @bakaoh