mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-13 22:43:59 +08:00
Summary: Adding documentation for the CLI for 2 reasons: 1. It's not immediately clear to most how the CLI is part of `react-native` and not the node module they installed. This begins clarifying. 2. I plan on adding some additional documentation to this section pending an upcoming PR I've discussed with Mike. screen shot provided:  Closes https://github.com/facebook/react-native/pull/11097 Differential Revision: D4237028 Pulled By: mkonicek fbshipit-source-id: c1dc50fe1be7f6947a33ee6472b5862306888055
63 lines
2.5 KiB
Markdown
63 lines
2.5 KiB
Markdown
---
|
|
id: upgrading
|
|
title: Upgrading
|
|
layout: docs
|
|
category: Guides
|
|
permalink: docs/upgrading.html
|
|
next: platform-specific-code
|
|
previous: understanding-cli
|
|
---
|
|
|
|
Upgrading to new versions of React Native will give you access to more APIs, views, developer tools
|
|
and other goodies. Because React Native projects are essentially made up of an Android project, an
|
|
iOS project and a JavaScript project, all combined under an npm package, upgrading can be rather
|
|
tricky. But we try to make it easy for you. Here's what you need to do to upgrade from an older
|
|
version of React Native:
|
|
|
|
## 1. Upgrade the `react-native` dependency
|
|
|
|
Note the latest version of the `react-native` npm package from here (or use `npm info react-native` to check):
|
|
|
|
* https://www.npmjs.com/package/react-native
|
|
|
|
Now install that version of `react-native` in your project with `npm install --save`:
|
|
|
|
```sh
|
|
$ npm install --save react-native@X.Y
|
|
# where X.Y is the semantic version you are upgrading to
|
|
npm WARN peerDependencies The peer dependency react@~R included from react-native...
|
|
```
|
|
|
|
If you saw a warning about the peerDependency, also upgrade `react` by running:
|
|
```sh
|
|
$ npm install --save react@R
|
|
# where R is the new version of react from the peerDependency warning you saw
|
|
```
|
|
|
|
## 2. Upgrade your project templates
|
|
|
|
The new npm package may contain updates to the files that are normally generated when you
|
|
run `react-native init`, like the iOS and the Android sub-projects.
|
|
|
|
You may consult [rn-diff](https://github.com/ncuillery/rn-diff) to see if there were changes in the project template files.
|
|
In case there weren't any, simply rebuild the project and continue developing. In case of minor changes, you may update your project manually and rebuild.
|
|
|
|
If there were major changes, run this in a terminal to get these:
|
|
|
|
```sh
|
|
$ react-native upgrade
|
|
```
|
|
|
|
This will check your files against the latest template and perform the following:
|
|
|
|
* If there is a new file in the template, it is simply created.
|
|
* If a file in the template is identical to your file, it is skipped.
|
|
* If a file is different in your project than the template, you will be prompted; you have options
|
|
to view a diff between your file and the template file, keep your file or overwrite it with the
|
|
template version. If you are unsure, press `h` to get a list of possible commands.
|
|
|
|
|
|
# Manual Upgrades
|
|
|
|
Some upgrades require manual steps, e.g. 0.13 to 0.14, or 0.28 to 0.29. Be sure to check the [release notes](https://github.com/facebook/react-native/releases) when upgrading so that you can identify any manual changes your particular project may require.
|