-
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 reload not working with webpack2 and react-hot-loader3 #354
Comments
@calesce I know this project is not build as a simple project this is a boilerplate for a enterprise grade react application. The re reqeuire is not needed as I use the new webpack2 with es6 modules system (There is actual comments in this project that it is not needed). In addition I've added some console.log in the hot accept and that method never gets called. |
Again, I haven't yet looked at this deeply, but if you're saying that |
It's just that the module id chane that the error message displays does not contain the module id of my DevAppRoot (which is the component that is rendered). Thats why I assume that its a react hot loader issue. It somehow looses track of my Root component (maybe because of react router?) |
Ah, ok. Have you tried removing the React Router bits to try to isolate the issue and see whether it's the same problem as the other React Router issues? |
I'm having the same issue, seems like React Router is indeed causing it. When I use simple React components, hot reloading works well. |
So here are my findings: I had import React from 'react'
import { Route, IndexRoute } from 'react-router'
import Home from './components/Home'
const routes =
<Route path="/" component={Home} />
export default routes And import React, { Component } from 'react'
import { Router, browserHistory } from 'react-router'
import routes from '../routes'
const Root = () =>
<Router
history={browserHistory}
>{routes}</Router> This combination led to Seemed like the |
Found the root of the problem: My |
@elado thank you! I have a same problem too! |
But that shouldn't be a problem? I thought react router is suppose to work in this way too? The old school way of hot reloading (using the babel plugin) was working perfect for this scenario. |
I even removed react-router from my app, now my app is just two modules, and I still get these: |
@Ciantic can you share a simple repo showing the issue? |
cc @calesce I just upgraded another project to latest beta (5). It's not reloading components that are directly or indirectly imported into the For example:
|
So the problem could be that my main.js file imports the routes and just passes them to my root component instead of my root component importing the routes? |
@elado you'll need to add that to the array for @fkrauthan I'm not sure, but I wasn't able to clone, install and run your project, I got this error: |
@calesce thanks. Is this requirement new for 3-beta? Same code worked fine with 1.3.0. |
@elado: for React components it wasn't required in 1.x because |
@calesce I've pushed a new version with fixes (and a shrinkwrap file to make sure that the dependencies are going to be the same). I found out that not my Edit
But the component itself is still showing the old content. |
Hi all;
I have an example set up in my _Update_: turns out I didn't have the babel plugin included in my example above. Unfortunately RHL3 doesn't play nicely with the declarative |
Hi there. Trying to setup from scratch I've got one problem - HMR logs is OK in console, but browser content doesn't updates. I'm runing webpack-dev-server CLI with --hot --inline options. |
@ElForastero A simple, runnable project would be more helpful. |
trying to separate vendor and app in the entry everything is fine but the reload.
[WDS] App updated. Recompiling... the only working combination I did is |
@sylhero I don't usually use multiple entry points, but doesn't the |
@calesce thanks for your reply! I just tried your suggestion but unfortunately I got the same problem everything is fine it just doesn't reload |
@calesce after some experiments I finally found something that works for me now:
I deleted node_modules and update my npm to 4.0.1 now it works. Thanks for your help! |
interesting, you left the |
@sylhero so your solution was to define the app.jsx plus your actual index.jsx in webpack? Instead of just the index.jsx (which in my opinion should be enough?) |
@fkrauthan you are right. eventually I may merge them together. Now, it's just for testing multiple entrance + commonchunckplugin. |
I want to say that I noticed exactly the same as @ctrlplusb:
If I swap |
I solved a similar problem. I had the issue with hot.module.accept not triggering when I switched to webpack2. I simply saw nothing relating to HMR in the console, but WDS printed the normal stuff about I had to simply update to webpack2: Previously I was running |
@pgsandstrom That was a most excellent tip and cleared up many days of headache. Thanks! |
@pgsandstrom , thanks, it's simple way for solve my issue 👯 |
@pgsandstrom thanks!! In fact, since yesterday you can do just npm install webpack-dev-server --save-dev and will be installing version 2.2.1. |
@pgsandstrom I had been wresting with this issue on and off for a couple of days now. Thanks for the tip, after I switched to EDIT: I actually upgraded to |
I can also confirm that after upgrading to Webpack v2.2, react-hot-loader 3 stopped working. Installing |
Did |
I have to give it a try later next week. Will update this ticket as soon as possible. We could also close it for now and I just comment on here in case it still is an issue? |
We'll wait couple more days until you verify it was the case. Thanks! |
I just updated my code to use webpack 2.2.1 and webpack-dev-server 2.4.1 And it looks like the step into the right direction. Now I get: My current reload code looks like this: // Render with devtools if enabled
if (__DEVTOOLS__ && !window.devToolsExtension) {
const DevAppRoot = require("./components/DevAppRoot").default;
ReactDOM.render(
<AppContainer errorReporter={errorReporter}>
<DevAppRoot store={store} history={history} routerRender={applyRouterMiddleware(useScroll())} routes={createRoutes(store, reducerRegistry)} />
</AppContainer>,
dest
);
// Listen for hot replacement
if (module.hot) {
module.hot.accept(['./components/DevAppRoot', '../common/routes/create'], () => {
const NewDevAppRoot = require("./components/DevAppRoot").default;
ReactDOM.render(
<AppContainer errorReporter={errorReporter}>
<NewDevAppRoot store={store} history={history} routerRender={applyRouterMiddleware(useScroll())} routes={createRoutes(store, reducerRegistry)} />
</AppContainer>,
dest
);
});
}
} |
But interesting enough it still seems to hot reload correctly regardless of that warning. So i guess this ticket can be closed. I might gonna switch to the new react router anyways. |
Ok, so I'll close this one. Problems and solutions with React Router v3 are being discussed here: #288. BTW switching to React Router v4 should definitely solve the problems. |
@ElForastero did you figure it out? |
Try to perform NPM upgrade and reinstall node-modules. npm install -g npm |
I updated my small project to webpack2 and switched to react-hot-loader3 but now everytime I try to change a react component I just get the following output:
Right now it does not even try do a full reload anymore. The Source code can be found here: https://gitlab.fkrauthan.de/simply-sailing/west-coast-sailing-club
Just run
npm install
in the web-ui folder and after that runnpm start webpack:development
The file I try to change is in web-ui/src/common/modules/static/components/HomePage.js
The text was updated successfully, but these errors were encountered: