Open nahuelarjonadev opened 5 years ago
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/
Description
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:index.js
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.jsSo that's why i'm using the (old) index.js approach.
Environment (obtained from yarn.lock)
Deps:
System:
Reproducible Demo
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 byyarn dev
should be enough to try it.