Hot reloading with create-react-app without ejecting 🔥 ⏏️

…and without react-app-rewired.

Image for post
Image for post
Very awesome but way-too-serious photo for this article because I guess the theme is “hot”? So, like “fire”? Aziz Acharki on Unsplash
Gist from Charlie Gleason’s post on “Hot Reloading + create-react-app"

There’s a “webpack-shaped” hole in my brain

Attempting to understand

API

if (module.hot) {
module.hot.accept('./library.js', function() {
// Do something with the updated library module...
})
}
if (module.hot) {  
module.hot.accept('./App', () => {
const NextApp = require('./App').default;
// render with new App here
});
}

Other cool stuff

{
entry: [
require.resolve('react-dev-utils/webpackHotDevClient'),
],
}
require.resolve(‘webpack-dev-server/client’) + ‘?/’, require.resolve(‘webpack/hot/dev-server’),

Links

Written by

UX Developer @ Indeed // Previously: Accenture, IBM, Carbon Design System

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store