Skip to content

Instantly share code, notes, and snippets.

@klzns klzns/index.js
Created Aug 15, 2017

Embed
What would you like to do?
How to add hot module replacement (react-hot-loader) in Create React App
import { AppContainer } from 'react-hot-loader' // Install `npm install react-hot-loader@next`
import React from 'react'
import App from './App'
const renderApp = (Root) => {
React.render(
<AppContainer>
<Root />
</AppContainer>,
document.getElementById('app-root')
)
}
renderApp(App)
if (module.hot) {
module.hot.accept('./App', () => {
const NewApp = require('./App').default
renderApp(NewApp)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.