A simple project is actually very simple to set up and run.
The essence is: first install node.js, then install react-native-cli, the command line tool, then use the react-native command line tool to create the project, and finally use the command to run the project. Four steps.
The first is the installation of nodejs. The installation of nodejs is related to your operating system. There are a lot of information, so I won't go into details.
Why install node.js first? Because almost all JS front-end ecosystems are now revolving around npm (Node package manager).
After installing node.js, use npm to install the command line interface of react-native, which is react-native-cli,
The command is:
npm install -g react-native-cli
As for the commands on the RN Chinese website:
npm install -g yarn react-native-cli
In fact, yarn and react-native-cli are installed together at once.
After the above command is installed, you can execute the following command,
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
The function of the first command is to create an RN project
react-native init AwesomeProject
The function of the second command. . . Is to enter this project (not to mention this, I guess everyone knows it)
cd AwesomeProject
The function of the third command is to run the created RN project.
react-native run-android
If you have opened the Android emulator at this time, congratulations, the first RN application should already be running.
The effect after running is as follows:
It's actually very simple, right?
Also, in order to view the console output of the RN project, we need to install watchman, but I won't go into details here. You can go to the official website of RN or the Chinese website to check the content.
The link is as follows:
RN Chinese Network
https://reactnative.cn/docs/0.51/getting-started.html
RN official website
http://facebook.github.io/react-native/docs/getting-started.html