-
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
content doesn't reload #511
Comments
I'm experiencing the same problem. I've got a project where components that has state injected from the store will not reload and the same goes for all child components to those components. However components without store connection or ancestors reloads just fine. Versions:
|
I got this working now. There were two things I needed to change. and then I tried what someone suggested here webpack/webpack-dev-server#100 (comment) ..and re-imported the App component inside Like this:
|
@sylhero could you try to put |
@wkwiatek thanks for replying me. I tried your suggestion but still not working. I can not provide a repo but it's easy to reproduce. |
@HeyHugo thanks for the solution! |
@HeyHugo Thank for the solution! It works well! |
I did not need to move the if (module.hot) {
module.hot.accept('./App', () => {
const App = require('./App').default;
render(App);
});
} I fought with this a long while, so for anyone else here's the basics of my setup for react / redux / react-router v4. // index.js (the entrypoint for webpack)
require('../css/index.scss');
require.context('../images', true, /^\.\//);
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import { Provider } from 'react-redux';
import { compose, createStore } from 'redux';
import persistState from 'redux-localstorage';
import rootReducer from './state';
const enhancer = compose(
persistState('settings'),
);
const initialState = undefined; // eslint-disable-line no-undefined
const store = createStore(rootReducer, initialState, enhancer);
import App from './App';
const rootEl = document.getElementById('Root');
// Render the main component into the dom
const render = (Component) => {
ReactDOM.render(
<AppContainer>
<Provider store={store}>
<Component />
</Provider>
</AppContainer>,
rootEl
);
};
render(App);
if (module.hot) {
module.hot.accept('./App', () => {
const App = require('./App').default;
render(App);
});
} // App.jsx
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import NavigationRoute from 'routes/NavigationRoute';
// Render the main component into the dom
export default class App extends React.Component { //eslint-disable-line react/require-optimization
render() {
return (
<BrowserRouter>
<NavigationRoute />
</BrowserRouter>
);
}
} // NavigationRoute.jsx (simplified)
import React from 'react';
import { Redirect, Route, Switch } from 'react-router';
import Header from 'components/Header';
import EmergencyRoute from 'routes/EmergencyRoute';
import MapRoute from 'routes/MapRoute';
import MoreRoute from 'routes/MoreRoute';
class NavigationRoute extends React.Component {
shouldComponentUpdate() {
return true;
}
render() {
return (
<div className='NavigationRoute'>
<Header />
<div className='NavigationRoute-content'>
<Switch>
<Route path='/emergency' component={EmergencyRoute} />
<Route path='/more' component={MoreRoute} />
<Route path='/map' component={MapRoute} />
<Redirect from='*' to='/map' />
</Switch>
</div>
</div>
);
}
}
NavigationRoute.propTypes = {};
export default NavigationRoute; |
I'm getting this too (see my mistakenly reported ticket here: webpack/webpack#4703) Is this |
@HeyHugo Hi. Thanks for the solution. If you reimport that module, in |
@HeyHugo It is works for me , thanks
BTW , when i use lazy loading , this is still not work for me |
For my case, it was caused by the .babelrc configuration. You need to config the babel to disable module transformation. I do the set as below: |
Keep in mind - when you don't use harmony modules, ie not transpiled |
The two modes (harmony and cjs) are now supported with new |
@ehe888 your comment solved my issue of my Home component not updating in the DOM/reloading the updated file into sources. The HMR console logging says "successful" but it never updated since source file was not being refreshed. Can you explain this more? i am new to Webpack & babel configs. This is my updated .babelrc file:
|
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
HMR is working but content is not reloading
What you are reporting:
bug
Expected behavior
content gets reloaded
What you think should happen:
Actual behavior
What actually happens:
Environment
windows 8.1 npm 4.1.1 "webpack": "^2.2.0", "webpack-dev-server": "^2.4.1", "react-hot-loader": "^3.0.0-beta.6", "react-redux": "^4.4.6",
React Hot Loader version:
"react-hot-loader": "^3.0.0-beta.6"
Run these commands in the project folder and fill in their results:
node -v
: 6.9.4npm -v
: 4.1.1Then, specify:
Reproducible Demo
Please take the time to create a new project that reproduces the issue.
in the index.jsx
in .babelrc
in webpack.config.js
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.
I think what cause the problem is the
Provider
if I don't use it it works finePush to GitHub and paste the link here.
The text was updated successfully, but these errors were encountered: