react-app-rewire-hot-loader
Add the react-hot-loader
to your create-react-app
app via react-app-rewired
.
Because who wants their app, state, and styles automatically reloading all the time?
Installation
npm install --save react-app-rewire-hot-loader
npm install --save react-app-rewired
npm install --save react-hot-loader
Usage
- In the
config-overrides.js
of the root of your project you created for react-app-rewired
add this code:
const rewireReactHotLoader = require('react-app-rewire-hot-loader')
module.exports = function override (config, env) {
config = rewireReactHotLoader(config, env)
return config
}
Mark your root component as hot-exported:
import React from 'react'
import { hot } from 'react-hot-loader'
const App = () => <div>Hello World!</div>
export default process.env.NODE_ENV === ādevelopmentā ? hot(module)(App) : App
- Replace 'react-scripts' with 'react-app-rewired' in package.json
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-app-rewired eject"
},
That's it, you now have hot reloads!
License
Licensed under the MIT License, Copyright Ā©ļø 2017 Chris Harris. See LICENSE.md for more information.
[2.0.1] - 2019-02-09
Fixed
Fix hot loading by adding custom a Babel plugin injector function. @olafaloofian