Update Counter example to React Hot Loader 3

This commit is contained in:
Dan Abramov 2016-04-18 13:28:16 +01:00
parent 25eab60562
commit 251c85c93d
4 changed files with 26 additions and 8 deletions

View File

@ -1,3 +1,4 @@
{
"presets": ["es2015-loose", "stage-0", "react"]
"presets": ["es2015-loose", "stage-0", "react"],
"plugins": ["react-hot-loader/babel"]
}

View File

@ -16,8 +16,8 @@
},
"homepage": "https://github.com/gaearon/redux-devtools#readme",
"dependencies": {
"react": "^0.14.6",
"react-dom": "^0.14.6",
"react": "^15.0.1",
"react-dom": "^15.0.1",
"react-redux": "^4.1.0",
"redux": "^3.1.1",
"redux-thunk": "^1.0.3"
@ -30,10 +30,10 @@
"babel-preset-react": "6.3.13",
"babel-preset-stage-0": "^6.3.13",
"node-libs-browser": "^0.5.2",
"react-hot-loader": "^1.3.0",
"react-hot-loader": "^3.0.0-alpha.8",
"redux-devtools": "^3.0.1",
"redux-devtools-log-monitor": "^1.0.2",
"redux-devtools-dock-monitor": "^1.0.1",
"redux-devtools-log-monitor": "^1.0.2",
"webpack": "^1.9.11",
"webpack-dev-server": "^1.9.0"
}

View File

@ -1,11 +1,27 @@
import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import configureStore from './store/configureStore';
import Root from './containers/Root';
const store = configureStore();
render(
<Root store={store} />,
<AppContainer
component={Root}
props={{ store }}
/>,
document.getElementById('root')
);
if (module.hot) {
module.hot.accept('./containers/Root', () => {
render(
<AppContainer
component={require('./containers/Root').default}
props={{ store }}
/>,
document.getElementById('root')
);
});
}

View File

@ -6,6 +6,7 @@ module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'react-hot-loader/patch',
'./src/index'
],
output: {
@ -28,12 +29,12 @@ module.exports = {
module: {
loaders: [{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
loaders: ['babel'],
exclude: /node_modules/,
include: path.join(__dirname, 'src')
}, {
test: /\.js$/,
loaders: ['react-hot', 'babel'],
loaders: ['babel'],
include: path.join(__dirname, '..', '..', 'src')
}]
}