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:
react-native
dependency #Note the latest version of the react-native
npm package from here:
Open your package.json
file and update the version of react-native
under dependencies
to the
latest version. Now, in a terminal run:
The new npm package will likely contain updates to the files that are normally generated when you
run react-native init
, like the iOS and the Android sub-projects. To get these latest changes,
run this in a terminal:
This will check your files against the latest template and perform the following:
h
to get a list of possible commands.Xcode project format is pretty complex and sometimes it's tricky to upgrade and merge new changes.
The major change in this version happened to the CLI (see changelog) and static images (see docs). To use the new asset system in existing Xcode project, do the following:
Add new "Run Script" step to your project's build phases:
Set the script to
Move main.jsbundle to Trash (it will be generated automatically by Xcode using the script above)
If you installed Node via nvm, you might experience "react-native: command not found". See issues/3974 for workaround and pull/4015 for the fix.