Skip to content

Instantly share code, notes, and snippets.

@banjeremy
Created July 31, 2016 20:10
Show Gist options
  • Save banjeremy/9c7fcdef588f239779ae4c7efa1e1dd7 to your computer and use it in GitHub Desktop.
Save banjeremy/9c7fcdef588f239779ae4c7efa1e1dd7 to your computer and use it in GitHub Desktop.
HMR for create-react-app
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
const rootEl = document.getElementById('root');
ReactDOM.render(
<App />,
rootEl
);
if (module.hot) {
module.hot.accept('./App', () => {
const NextApp = require('./App').default;
ReactDOM.render(
<NextApp />,
rootEl
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment