Refer to the react Chinese: react.docschina.org/docs/how-to…

The React Chinese website offers a way to run the code:

Command lines in the image:

  • yarn build react/index,react-dom/index --type=UMD
  • fixtures/packaging/babel-standalone/dev.html

React

  • Find the React official address from Github

Github address: github.com/facebook/re…

  • Take the code library to the local (because the code library is relatively large, it takes a long time, I directly download the ZIP package)

git clone https://github.com/facebook/react.git

Install dependencies

As shown in the following figure, execute YARN in the root directory of the warehouse.

Install dependencies in native code as per the official website:

Pack react and react-dom

Run yarn build react/index,react-dom/index –type=UMD in the root directory to generate the packed file.

The generated files are in the root directory /build/node_modules/

Run the packaged code

findRoot directory/fixtures/packaging/Babel - standalone/dev. HTMLFile, you can see that these three files are loaded.

Open dev.html in your browser and see hello World rendered

conclusion

React/react-dom can be packed and run directly via dev.html. For later learning, I will directly copy the files to a new empty project. Github address :github.com/dai12544737…

If you want to learn together, you can clone the code directly. Files in the source directory of the project are directly copied from the package, and I will not modify the contents in the directory. Codes in the Packages directory before react are not packaged can be compared and learned.

The react code package is suitable for local debugging. See the React source code for details.

If you find any problems or mistakes in my learning method, please kindly point them out if you have time. Thank you very much