In-depth introduction to React Native 2: My first application, reactnative

Source: Internet
Author: User

In-depth introduction to React Native 2: My first application, reactnative

This is the second article in The React Native tutorial.

1. Environment Configuration

After the React Native environment is configured, you can start to create our first App.

Open the console, enter

react-native init AwesomeProject

The preceding command creates a project template named AwesomeProject in the current folder. Before running this command, run the cd command to the folder where you want to create react native.

Of course, it may take a long time to execute this command, and sometimes there may be various errors, such as no permission. In this tutorial, we use an initial project to modify and use it. The address is as follows:

Github: https://github.com/CellChen/react-native-init

After the download, find the tar folder, which is the project we need.

The project file is as follows: (this tutorial is mainly for iOS development. Therefore, the android and iOS directories are similar .)

It can be seen that the project mainly consists of index. ios. js and ios projects.

Open the console and make sure that the directory to which the current console is directed is AwesomeProject. Enter

npm start

 

This command is mainly used to start the local server for development.

After the server is started, you can use xcode to open the ios project, compile and run it, and you can see this most initial project ~~

We can try to modify the index. ios. js file to see the effect ~

Use the file editor (sublime is recommended for personal use, which is nice-looking, easy-to-use, and many plug-ins ~) Open index. ios. js and you can see the following code:

Modify 20th lines of code"This is my first React Native application"

Switch back to the iphone simulator and refresh CMD + R. You can see that the title on the simulator is changed to our latest modified text ~ (If the command + R refresh shows the previous text, you can stop the server and re-open it ~)

Well, the above is our first React Native application. It doesn't matter if you don't understand the code in the project. It will be explained later ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.