Created
February 12, 2018 16:03
-
-
Save dong-qian/5209154de4070ee68f5078c0c1d508a2 to your computer and use it in GitHub Desktop.
HRM + create-react-app + redux
This file contains hidden or 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
// index.js | |
ReactDOM.render(<App /> , document.getElementById('root')) | |
if (module.hot) { | |
module.hot.accept('./App', () => { | |
ReactDOM.render(<App />, document.getElementById('root')) | |
}) | |
} | |
// store.js | |
import { createStore } from 'redux' | |
import rootReducer from './reducers' | |
const configureStore = () => { | |
const store = createStore(rootReducer) | |
if (process.env.NODE_ENV !== "production") { | |
if (module.hot) { | |
module.hot.accept('./reducers', () => { | |
store.replaceReducer(rootReducer) | |
}) | |
} | |
} | |
return store | |
} | |
export default configureStore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment