Skip to content

Instantly share code, notes, and snippets.

@mtheoryx
Created June 30, 2017 16:21
Show Gist options
  • Save mtheoryx/cd974cb4bd8fb371c827211787eb2d1f to your computer and use it in GitHub Desktop.
Save mtheoryx/cd974cb4bd8fb371c827211787eb2d1f to your computer and use it in GitHub Desktop.
Create React App with HMR (Hot Module Replacement)
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
// Enable HMR
if (module.hot) {
module.hot.accept('./App', () => {
ReactDOM.render(<App />, document.getElementById('root'));
})
}
//Using Redux
// 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