-
Notifications
You must be signed in to change notification settings - Fork 127
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
HMR not working #214
Comments
Added a pull request to your example, this seems to work with es6 classes for some reason. batusai513/hmr-example#1 |
@standayweb thanks for that hint, i'll dig on this |
hey i just wanted you to know that i have the same problem. |
@flexzuu this is a weird issue, hope the maintainers can check at this anytime soon |
@flexzuu at the moment you can use class components, or use |
@batusai513 can you tell me some more details on the ?reload=true thing? I dont want to switch to class components only for the sake of hot reloading. |
@flexzuu if you are following the example, var config = getConfig({}), then you can: if(process.env.NODE_ENV == 'development'){
config.entry[0] = config.entry[0] + '?reload=true';
} but you should totally replace react-hmr for react-hot-loader 3, that worked like a charm; as soon as i arrive to my home, i'll send you what i did. |
@batusai513 I added an issue for upgrading to react hot loader 3. #213 Could you please do a pull request, or send what you did and I'll do one. Thanks! |
@flexzuu i succesfully implemented react-hot-loader@3.0.0-beta.2, now i have hmr for all my components, including functional stateless components, this is my var path = require('path');
var getConfig = require('hjs-webpack');
var webpack = require('webpack');
var config = getConfig({
in: 'app/main.js',
out: 'dist',
clearBeforeBuild: '!(images|favicon.ico)'
});
if(process.env.NODE_ENV === 'production'){
config.plugins[4] = new webpack.optimize.UglifyJsPlugin({
mangle: {
except: ['$inject', 'elementRegistry', 'modeling']
},
compress: {
warnings: false
},
output: {
comments: false
},
sourceMap: false
});
}
if(env == 'development'){
config.entry[0] = config.entry[0] + '?reload=true';
config.entry.unshift('react-hot-loader/patch');
}
config.resolve.root = path.resolve('.');
config.module.loaders.push({
test: /\.(js|jsx|babel)$/,
loaders: ['babel', 'eslint'],
exclude: /node_modules/
});
module.exports = config;
{
"presets": ["es2015", "stage-0", "react"],
"env": {
"development": {
"plugins": ["react-hot-loader/babel"]
}
}
} i had to create an import React from 'react';
import { Provider } from 'react-redux';
import getRoutes from './routes';
import {authService} from './helpers/api/auth';
function checkAuth(nextState, replace){
var nextPathName = nextState.location.pathname;
if(nextPathName == "/login"){
if(authService.loggedIn()){
replace({
pathname: '/',
state: { nextPathName: nextPathName }
});
}
}else{
if(!authService.loggedIn()){
replace({
pathname: '/login',
state: { nextPathName: nextPathName }
});
}
}
}
export default function App({store, history}){
return (
<Provider store={store}>
{getRoutes(history, checkAuth)}
</Provider>
);
} and in my import 'babel-polyfill';
import React from 'react';
import ReactDOM, {render} from 'react-dom';
import {browserHistory} from 'react-router';
import { AppContainer } from 'react-hot-loader';
import createStore from './create-store';
import App from './app';
import './styles/main.scss';
import startInitializers from './initializers';
const {store, history} = createStore(browserHistory, {});
startInitializers(store.dispatch, store.getState);
var rootEl = document.getElementById('root');
export default render(
<AppContainer>
<App store={store} history={history} />
</AppContainer>,
rootEl
);
if (module.hot) {
module.hot.accept('./app', () => {
const NextApp = require('./app').default;
render(
<AppContainer>
<NextApp store={store} history={history} />
</AppContainer>,
rootEl
);
});
} |
@batusai513 hey thanks for the info. I just added the hot reloading to my config. I will look into the hot reloader 3 but i might wait for an update on hjs-webpack.
|
Thanks for all the debugging in this thread! I'm sure it's helpful to others. I've been waiting to transition this to |
Hi, first, i want to thank you for this package, it has been really helpful.
I've been facing some problems with the Hot module replacement lately, whenever i save a component, it doesn't inject the new component as it used to.
I`ve made a small repo for you to test what can be happening
https://github.com/batusai513/hmr-example
Thanks for your help
The text was updated successfully, but these errors were encountered: