-
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
React module is not hot updated after my upgrade of webpack to v2 and webpack-dev-server to v2 #469
Comments
It worked fine after I removed react-router. |
@vivaxy what are you using instead of react-router? I'm hitting the same problem. |
@nikolaipaul It's not fixed. I removed react-router just to find out what part causes this problem. |
Having the same problem with React Router v3.0.2 (Webpack 2.2.1, react hot loader 3.0.0-beta.6). I also see the warning:
|
@vivaxy @nikolaipaul this fixed my issue, have you tried it? #240 (comment) i currently have:
rather than |
@bjudson I tried, It's still not working. I've noticed that repo does not use react-router. |
Not too concerned about the warning, as long as it works :) I am using react-router, and above fix worked for me. Not really sure react-router was my problem though. |
I think problem is related to RR v3, and we have an issue for that: #288. Please feel free to reopen if there's something more. Thanks! |
It just worked after my several updates. |
I've had the same issue without react-router. @bjudson's fix worked for me, are there any downsides to using this? |
@andyearnshaw @IgorGee could you share some repository with minimal reproduction scenario? I'll try to understand why you needed to add such a workaround. In case of code from @akoskm and @bjudson (#240 (comment)) it should not be needed as the path says to webpack which code should be allowed to hot update. If you remove that path, then every change from outside will also cause hot update instead of full reload which potentially can have unexpected results. |
@wkwiatek sure, here ya go: react-boilerplate Edit: To reproduce: replace
and then try to change any text within App or Title |
Thanks for that. I quickly went through, and it seems your code is probably not using ES2015 imports from webpack. Following code fixes the issue: module.hot.accept('./components/App', () => {
const NextApp = require('./components/App').default
render(NextApp)
}) However, it should not be required when using webpack ES2015 built-in imports. To have that, in your This is how to use {
"presets": [
["latest", {
"es2015": {
"modules": false
}
}]
]
} I'll mention it in the docs. |
@wkwiatek that doesn't seem to be the problem for me. This is my
This makes it still sound like a bug. If you provide a path it doesn't update, if you don't provide a path it updates. Whether the issue is with webpack or react-hot-loader, I don't know. |
If you provide a path, and have ES2015 modules by webpack, then you only need to have this: module.hot.accept('./components/App', () => {
render(App)
}) But if you use babel transform for modules, then code looks like this: module.hot.accept('./components/App', () => {
const NextApp = require('./components/App').default
render(NextApp)
}) It's not a bug, it's how it works with and without transforming es2015 modules. It's also stated in docs/migration guide. Of course you can say that any change in any file will trigger hot reload and hot update (not only the |
Thanks @wkwiatek, that .babelrc fix did the trick. For anyone writing their webpack config in ES6, this babel configuration won't run your webpack config. I solved it by moving my webpack files into a separate directory with its own .babelrc. |
@wkwiatek, I've added a slight bit of complexity to my boilerplate and it goes back to the same behavior originally posted. But I do have additional information. All I've done is add a
|
thank you @bjudson I spent hours trying to make HMR work again - your comment seems to have fixed it for now. |
@bjudson - I spent like two days getting it to work before finding your comment, you're a lifesaver. |
my hot reload works now. but only once. after that the state in all components below Root is lost. any idea why? if (module.hot) {
module.hot.accept(() => {
const NewRoot = require('./containers/Root').default;
ReactDOM.render(
<AppContainer>
<NewRoot store={store} history={history} />
</AppContainer>,
document.getElementById('root')
);
});
} |
Thanks @bjudson - This resolved my issue as well |
@bjudson That was exactly the problem!! Wow, I think a lot of the boilerplate samples need to be updated to reflect this. I wasted half a day chasing down this issue. |
- required a change in the parameters passed to module.hot.accept gaearon/react-hot-loader#469 (comment)
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
React module is not updated, after I edited
./src/components/DemoButton.js
, changed something.Expected behavior
Modules updated.
Actual behavior
Update traces are correct.
Breakpoints in render method was called. But nothing happened in DOM tree.
Environment
React Hot Loader version: 3.0.0-beta.6
Run these commands in the project folder and fill in their results:
node -v
: v6.6.0npm -v
: 3.10.3Then, specify:
Reproducible Demo
https://github.com/vivaxy/gt-react-scaffold/tree/db4a02582452772ac4533b3b0f199e831f339578
The text was updated successfully, but these errors were encountered: