Upgrading to new versions of React Native will give you access to more APIs, views, developer tools and other goodies. Upgrading requires a small amount of effort, but we try to make it easy for you. The instructions are a bit different depending on whether you used
react-native init to create your project.
Upgrading your Create React Native App project to a new version of React Native requires updating the
expo package versions in your
package.json file. Please refer to this document to find out what versions are supported. You will also need to set the correct
sdkVersion in your
See the CRNA user guide for up-to-date information about upgrading your project.
react-native-git-upgrade provides a one-step operation to upgrade the source files with a minimum of conflicts. Under the hood, it consists in 2 phases:
IMPORTANT: You don't have to install the new version of the
react-nativepackage, it will be installed automatically.
While your project does not have to be handled by the Git versioning system -- you can use Mercurial, SVN, or nothing -- you will still need to install Git on your system in order to use
react-native-git-upgrade. Git will also need to be available in the
react-native-git-upgrade module provides a CLI and must be installed globally:
Run the following command to start the process of upgrading to the latest version:
You may specify a React Native version by passing an argument:
The templates are upgraded in a optimized way. You still may encounter conflicts but only where the Git 3-way merge have failed, depending on the version and how you modified your sources.
Conflicted files include delimiters which make very clear where the changes come from. For example:
You can think of "ours" as "your team" and "theirs" as "the React Native dev team".
Use this only in case the above didn't work.
Note the latest version of the
react-native npm package from here (or use
npm info react-native to check).
Now install that version of
react-native in your project with
npm install --save:
If you saw a warning about the peerDependency, also upgrade
react by running:
The new npm package may contain updates to the files that are normally generated when you
react-native init, like the iOS and the Android sub-projects.
You may consult 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:
This will check your files against the latest template and perform the following:
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 when upgrading so that you can identify any manual changes your particular project may require.
You can edit the content above on GitHub and send us a pull request!