Skip to content

Instantly share code, notes, and snippets.

@superhighfives
Last active September 25, 2018 13:19
Show Gist options
  • Save superhighfives/3e9f0f3d2770993ca5e7270863872803 to your computer and use it in GitHub Desktop.
Save superhighfives/3e9f0f3d2770993ca5e7270863872803 to your computer and use it in GitHub Desktop.
Hot reloading with 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