-
-
Save bmorwood/4481a6838188362d2c8bbb77ae530dfd to your computer and use it in GitHub Desktop.
HRM + create-react-app + redux
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
// 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