https://github.com/James2516/hot-reload
I'm trying to add hot loader to an existing webpack project.
It detected file changes but did not reload the component.
To reproduce:
yarn && yarn start
- change
src/App.js
content
https://github.com/James2516/hot-reload
I'm trying to add hot loader to an existing webpack project.
It detected file changes but did not reload the component.
To reproduce:
yarn && yarn start
src/App.js
contentCopyright © 2021 Jogjafile Inc.
The examples are taken from https://gaearon.github.io/react-hot-loader/getstarted/#step-2-of-3-using-hmr-to-replace-the-root-component, though it seems as though you already followed this guide.
The first problem is that
[HMR] Waiting for update signal from WDS...
is printed to the console twice, and any attempted recompiles also occur twice. This is caused by yourentry
in./config/webpack/Dev.js
being:The first few steps of the guide have the entry point as:
Step 3a under Step 3 (of 3): Adding React Hot Loader to preserve component state instructs you to modify the
entry
ofwebpack.config.js
to look like:react-hot-loader
handles what these two entries were previously doing, so they can be replaced with'react-hot-loader/patch'
.So your new entry point should be:
Next, Step 3b in the same section has a code snippet that looks like:
Changing your
module.hot
block to:Correctly reloads the component, so it doesn't make sense that following Step 3c breaks HMR.
Which you did correctly in
.babelrc
. The only problem is that in./config/webpack/Base.js
you have:This causes
babel-loader
to use these presets instead of the ones defined in.babelrc
. Removingquery
in this rule and changingpresets
in.babelrc
to:Correctly enables HMR with your
module.hot
block as: