- Full-Stack React Projects
- Shama Hoque
- 94字
- 2021-06-25 21:45:15
Marking the root component as hot-exported
The last line of code in App.js to export the App component uses the hot module from react-hot-loader to mark the root component as hot. This will enable live reloading of the React components during development.
mern-skeleton/client/App.js:
import { hot } from 'react-hot-loader'
...
export default hot(module)(App)
For our MERN applications, we won't have to change the main.js and App.js code all that much after this point, and we can continue building out the rest of the React app by injecting new components in the MainRouter component.