React Native Version upgrade and downgrade _react

Source: Internet
Author: User
React Native version upgrade and downgrade (1) Introduction
Now that React Native For Android has just been open source, it is not long ago that the overall functions are still not perfect and there are still a lot of bugs in development, so that there is no official version yet. The project staff is stepping up development and maintenance to fix the bug, so the version update speed of the React Native project is still relatively fast. Under such circumstances, we must pay close attention to the project's official website in a timely manner, and update React Native to the new version, so that we can use more APIs, view Views, and developer tools and other useful things.

We all know that a React Native project is composed of three parts: Android project, iOS project and JavaScript project, and all three are associated and packaged in the npm package, so updating the project version is relatively cumbersome. Let me explain the upgrade steps of the React Native project. (2) Upgrade React Native version View local React Native version

First, we need to check the local version of React Native. Enter the following command on the command line:

react-native --version
If it is created directly from the command line npm install -g react-native-cli according to the previous article, then the following situation should appear:

It is found that the version number is 0.2.0, which is actually the local cli version. At this time, you need to enter the React Native main directory that was created before executing react-native –version.

At this time, you can view the React Native version and cli version.

React Native version upgrade and downgrade You can also enter npm info react-native on the command line to view and return a JSON object, as shown below:
The latest version is currently 0.27.0-rc2, which is a preview version.
React Native 版本升级与降级_React

Let's take the AwesomeProject project created earlier as a test. Open the package.json file in the project, find the dependencies field, and modify the version of react-native to be higher than the current project version, as shown in the figure:

Next, switch to the main directory of the project and execute the following code. This installation process will take some time:

npm install

If the following interface appears, it means that the upgraded version is successful.

Next, run the react-native --version command in the project directory to view the current version:

The appeal method is to manually modify the configuration file to update. You can see from the official documentation that it is now supported to run the npm install --save command in the project to install the new version of react-native. For example, if you need to update to version 0.27, you can execute the following command :

npm install --save react-native@0.18
(3) Update project templates
The version of the project template will also change with different versions, so after updating the React Native version, the project template should also be updated in time.
Through the following command:

react-native upgrade
Run screenshot as follows:

[Do not heed] In the red box above, the file modification check will be carried out, choose to overwrite or keep the original file, depending on your actual situation, all choose not to overwrite here.
There are three principles: if it is a newly added file, it will be created directly. If the update file is the same as the original file, skip it directly. If the update file is different from the current project file, there is a conflict, and the developer will be asked to choose whether to overwrite or keep the original file. , Depends on the actual situation.

After the update is complete, run it to see if there are any problems. (4) Downgrade of React Native version

The React Native version has just been upgraded. Now if it is the latest version, but the latest version is not particularly stable, and you always encounter unexpected bugs during development, you can consider reducing to a more stable version. The same is the above two methods. The first one is to modify the package.json file; the second one is to directly execute npm install --save react-native @ version number.

After passing the appeal, do n’t forget to update the template.

react-native upgrade
Finally run it to see if there is a problem.

Reprinted from:
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: 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.