-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot updates not applied #581
Comments
Ok, I've created a simplified repo of my project: https://github.com/egorovli/react-hmr-test |
This one is related: webpack/webpack-dev-server#100 I managed to fix the issue by changing if (module.hot) {
module.hot.accept('./containers/Root', () => render(Root));
} to if (module.hot) {
module.hot.accept('./containers/Root', () => render(require('./containers/Root').default));
} Not sure if it's an intended behavior. https://github.com/gaearon/react-hot-boilerplate and https://github.com/wkwiatek/react-hot-loader-minimal-boilerplate both use this syntax, as well as official docs https://github.com/gaearon/react-hot-loader/tree/master/docs: if (module.hot) module.hot.accept('./App', () => render(App)); |
Or you can use: if (module.hot) {
module.hot.accept();
} But in my case this was throwing errors about |
const reactAppContainer = document.getElementById('reactAppContainer')
if (module.hot) {
module.hot.accept() // this is important
ReactDOM.render((<AppContainer><MainPage /></AppContainer>), reactAppContainer)
} else {
ReactDOM.render((<AppContainer><MainPage /></AppContainer>), reactAppContainer)
} appContainer use this. and setting with migration-to-3.0 |
Another case that may cause this is not having the |
@egorovli I spent hours to trying to get my rhl 3 update to correctly apply edits, then your solution with module.hot.accept() worked. The recommended way, with module.hot.accept(path, callback) failed silently - with "Component does not know how to update itself". I think there must be something about the relative paths or anything in my typescript setup that fails it. Is there any documentation/links on what this does, exactly - since we don't get the chance to explicitly call the render function again? Apart from the very annoying store error, are there any other disadvantages to using this simple syntax? UPDATE: I had an old version of the webpack-hot-middleware, this was most likely the cause of my problems. |
@egorovli this also works for me, with react v16 and webpack v3 |
@egorovli Thanks so much for your solution. I solved this problem with the help of your require and default solution. Do you know how that happened? Is there some error about the babel config? |
@egorovli thank you so muck. I don't know why, but i had wrong behavior when set code like of. doc |
Wow @egorovli I entered a new project recently, and noticed that our HMR wasn't working properly. No idea why, thought it might've been the way browsersync was set up. Regardless, simply using
did the trick. Still haven't figured out why though. |
@egorovli your solution also worked for me. Using React 16.3 and webpack v4. |
@dangdennis - that might be due to a bug in React-Hot-Loader v4, when it does nothing without babel (#923) |
how to use 'AppContainer' with 'react-router' and 'redux‘ together? |
Always use just |
can you provide some example? |
Any our example - just wrap with |
I'm currently experiencing a weird behavior, hot updates stopped working in my project some commits ago, and I can't figure out what caused it. Currently I'll ask a quick question in case anyone knows, if not, I'll try to reproduce it in an isolated environment.
Ok, everything seemed to work, but now hot updates stopped applying, however, console says that it's working:
I'm using
"react-hot-loader": "^3.0.0-beta.6"
, serving files from"webpack-dev-server": "^2.4.5"
:So basically all files are there at
http://localhost:8081/dist/js/admin.js
andclient.js
(entry points), all hot updates are there, as well, client app knows it should update and what updates should be applied (see screenshots of the console above), but nothing changes in the browser.Any help is very much appreciated.
The text was updated successfully, but these errors were encountered: