Home  >  Article  >  Web Front-end  >  How to implement hot update in react

How to implement hot update in react

藏色散人
藏色散人Original
2022-12-20 11:15:022898browse

How to implement hot update in react: 1. Use the "yarn add react-hot-loader -D" command to download "react-hot-loader"; 2. Add "react-hot-loader/babel" to enter ".babelrc" file; 3. Modify the code in App.js to "import { hot } from 'react-hot-loader/root';".

How to implement hot update in react

#The operating environment of this tutorial: Windows 10 system, react18 version, Dell G3 computer.

How to implement hot update in react?

[React] create-react-app implements hot update

1. Use the following command line to download react-hot-loader

yarn add react-hot-loader -D

or

npm install react-hot-loader

2. Add react-hot-loader/babel into the .babelrc file

// .babelrc
{
  "plugins": ["react-hot-loader/babel"]
}

3. Modify it to the following code in App.js

// App.js
import { hot } from 'react-hot-loader/root';
const App = () => <div>Hello World!</div>;
export default hot(App);

Recommended learning: "react Video tutorial

The above is the detailed content of How to implement hot update in react. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn