Description
If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.
Description
What you are reporting: when I user React.lazy, it doesn't work
Expected behavior
What you think should happen: state can remain
Actual behavior
What actually happens: state can't remain
Environment
React Hot Loader version: 4.12.19
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/preset-env": "^7.8.3",
"@babel/preset-react": "^7.8.3",
"babel-loader": "^8.0.6",
"express": "^4.17.1",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-middleware": "^3.7.2",
"webpack-dev-server": "^3.10.3",
"webpack-hot-middleware": "^2.25.0"
},
"dependencies": {
"@babel/runtime-corejs3": "^7.8.3",
"connected-react-router": "^6.7.0",
"history": "^4.10.1",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-hot-loader": "^4.12.19",
"react-redux": "^7.1.3",
"react-router-dom": "^5.1.2",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
}
Run these commands in the project folder and fill in their results:
node -v
: v12.15.0npm -v
: 6.13.4
Then, specify:
- Operating system: mac os
- Browser and version: chrome
Reproducible Demo
Please take the time to create a new project that reproduces the issue.
You can copy your project that experiences the problem and start removing things until you’re left with the minimal reproducible demo. This helps contributors, and you might get to the root of your problem during that process.
Push to GitHub and paste the link here.
you can use my project and reappear it : https://github.com/rainydayDY/webpack-fe
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
- chore(deps): bump react-hot-loader from 4.12.21 to 4.13.0backstage/backstage
- [Snyk] Upgrade react-hot-loader from 4.12.12 to 4.13.1TheJ-Erk400/devaccownt
- [Snyk] Upgrade react-hot-loader from 4.12.12 to 4.13.1TheJ-Erk400/devaccownt
- [Snyk] Upgrade: react, react-dom, asn1-ber, electron-debug, history, react-animated-css, react-copy-to-clipboard, react-hot-loader, react-json-view, react-motion-loop, react-redux, redux, redux-thunk, semantic-ui-css, source-map-supportkalbroni7/fairy-wallet
- [Snyk] Upgrade: react-dom, asn1-ber, electron-debug, history, react-animated-css, react-copy-to-clipboard, react-hot-loader, react-json-view, react-motion-loop, redux, redux-thunk, semantic-ui-css, source-map-supportkalbroni7/fairy-wallet
Activity
theKashey commentedon Feb 26, 2020
Your example is too big. I've just checked this example and it works perfectly.
However there are two "modes" RHL can handle
lazy
with. Please try another one.See Out-of-bound warning
By disabling
trackTailUpdates
you will activate another mode with a bit more aggressive lazy management.xyy94813 commentedon May 5, 2020
@theKashey
how to run the example ??
I run the newest example with error in browser:
xyy94813 commentedon May 6, 2020
Someone say it maybe
@hot-loader/react-dom
problem.hot-loader/react-dom#8 (comment)
But, It is not work for me without using
@hot-loader/react-dom
.I found a interesting thins when i debugger:
react-hot-loader
will target update function; The root component forceUpdate()React-Hot-Loader: some components were updated out-of-bound. Updating your app to reconcile the changes.
react-hot-loader/src/hot.dev.js
Lines 54 to 82 in 5e226f4
If i wrap lazy load component by
hot
, `module, everything work well.There are some question:
theKashey commentedon May 7, 2020
Found a problem in
tailUpdate
- any pure/memo component could stop this "secondary" update. So if your application is good written - you will experience this problem, but only if react-dom patch is not enabled.I don't have a "broken" example I am able to fix, so, @xyy94813 - could you try to use this version of
hot.dev.js
, and check is it helping in your case or not - https://github.com/gaearon/react-hot-loader/blob/b14f49b085a6b48b8eeadeeb1a4bf25c981dc71c/src/hot.dev.jsxyy94813 commentedon May 7, 2020
@theKashey
This version work well for me,even i set
trackTailUpdates
tofalse
.Is it a excepted?
xyy94813 commentedon May 7, 2020
@theKashey
Well... Looks like it has side effects
Each child node in the chunk will be re-mounted again.
I'm not sure what is your expectation.
theKashey commentedon May 7, 2020
The changes I've made could not cause remount. They were just about a bit more deeper updates.
xyy94813 commentedon May 8, 2020
I am stuck in confusion...
I write a minimized implementation...
Everything work well with
react-hot-loader@4.12.20
...PS: lazy-component will be re-mount too...
xuya227939 commentedon May 14, 2020
I have also encountered the same problem,How can I solve it, for example?
14 remaining items