-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #667 from rackt/explicitly-use-hmr
Change examples to explicitly use replaceReducer() for hot reloading
- Loading branch information
Showing
18 changed files
with
128 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import 'babel-core/polyfill'; | ||
|
||
import React from 'react'; | ||
import Root from './containers/Root'; | ||
import { Provider } from 'react-redux'; | ||
import App from './containers/App'; | ||
import configureStore from './store/configureStore'; | ||
|
||
const store = configureStore(); | ||
|
||
React.render( | ||
<Root />, | ||
<Provider store={store}> | ||
{() => <App />} | ||
</Provider>, | ||
document.getElementById('root') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import React from 'react'; | ||
import Root from './containers/Root'; | ||
import { Provider } from 'react-redux'; | ||
import App from './containers/App'; | ||
import configureStore from './store/configureStore'; | ||
|
||
const store = configureStore(); | ||
|
||
React.render( | ||
<Root />, | ||
<Provider store={store}> | ||
{() => <App />} | ||
</Provider>, | ||
document.getElementById('root') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import thunk from 'redux-thunk'; | ||
import rootReducer from '../reducers'; | ||
import reducer from '../reducers'; | ||
|
||
const createStoreWithMiddleware = applyMiddleware( | ||
thunk | ||
)(createStore); | ||
|
||
export default function configureStore(initialState) { | ||
return createStoreWithMiddleware(rootReducer, initialState); | ||
const store = createStoreWithMiddleware(reducer, initialState); | ||
|
||
if (module.hot) { | ||
// Enable Webpack hot module replacement for reducers | ||
module.hot.accept('../reducers', () => { | ||
const nextReducer = require('../reducers'); | ||
store.replaceReducer(nextReducer); | ||
}); | ||
} | ||
|
||
return store; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
import 'babel-core/polyfill'; | ||
import React from 'react'; | ||
import Root from './containers/Root'; | ||
import BrowserHistory from 'react-router/lib/BrowserHistory'; | ||
import { Provider } from 'react-redux'; | ||
import { Router, Route } from 'react-router'; | ||
import configureStore from './store/configureStore'; | ||
import App from './containers/App'; | ||
import UserPage from './containers/UserPage'; | ||
import RepoPage from './containers/RepoPage'; | ||
|
||
const history = new BrowserHistory(); | ||
const store = configureStore(); | ||
|
||
React.render( | ||
<Root history={new BrowserHistory()} />, | ||
<Provider store={store}> | ||
{() => | ||
<Router history={history}> | ||
<Route path="/" component={App}> | ||
<Route path="/:login/:name" | ||
component={RepoPage} /> | ||
<Route path="/:login" | ||
component={UserPage} /> | ||
</Route> | ||
</Router> | ||
} | ||
</Provider>, | ||
document.getElementById('root') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import { createStore, applyMiddleware, combineReducers } from 'redux'; | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import thunkMiddleware from 'redux-thunk'; | ||
import apiMiddleware from '../middleware/api'; | ||
import loggerMiddleware from 'redux-logger'; | ||
import * as reducers from '../reducers'; | ||
import rootReducer from '../reducers'; | ||
|
||
const reducer = combineReducers(reducers); | ||
const createStoreWithMiddleware = applyMiddleware( | ||
thunkMiddleware, | ||
apiMiddleware, | ||
loggerMiddleware | ||
)(createStore); | ||
|
||
// Creates a preconfigured store for this example. | ||
export default function configureStore(initialState) { | ||
return createStoreWithMiddleware(reducer, initialState); | ||
const store = createStoreWithMiddleware(rootReducer, initialState); | ||
|
||
if (module.hot) { | ||
// Enable Webpack hot module replacement for reducers | ||
module.hot.accept('../reducers', () => { | ||
const nextRootReducer = require('../reducers'); | ||
store.replaceReducer(nextRootReducer); | ||
}); | ||
} | ||
|
||
return store; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
import 'babel-core/polyfill'; | ||
|
||
import React from 'react'; | ||
import Root from './containers/Root'; | ||
import { Provider } from 'react-redux'; | ||
import App from './containers/App'; | ||
import configureStore from './store/configureStore'; | ||
import 'todomvc-app-css/index.css'; | ||
|
||
const store = configureStore(); | ||
|
||
React.render( | ||
<Root />, | ||
<Provider store={store}> | ||
{() => <App />} | ||
</Provider>, | ||
document.getElementById('root') | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { createStore } from 'redux'; | ||
import rootReducer from '../reducers'; | ||
|
||
export default function configureStore(initialState) { | ||
const store = createStore(rootReducer, initialState); | ||
|
||
if (module.hot) { | ||
// Enable Webpack hot module replacement for reducers | ||
module.hot.accept('../reducers', () => { | ||
const nextReducer = require('../reducers'); | ||
store.replaceReducer(nextReducer); | ||
}); | ||
} | ||
|
||
return store; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters