Upgrading to React Native v0.59
The stable version of React Native, version 0.59, was released on 12th March, 2019. Among other reasons why we should upgrade our projects to this version is the fact that it is this version that provides 64-bit libraries. Google requires that all applications have a 64-bit apk starting from 1st August 2019, and to build this 64-bit apk, we need React Native v0.59. So let’s take a look at how we can upgrade to this version.
- Open the package.json file and look for
react-native
in thedependencies
block. Update the value to 0.59.0 or 0.59.1. Then run the commandnpm install
at the project’s root directory. - To directly update React Native from the terminal, run the command
npm install react-native@0.59
at the project’s root directory. - It is often a good idea to keep the
react
version updated with the react-native version. Hence, we would be doing that as well. Again, this can be done in two ways, either by editing the value in the package.json file or directly from the terminal. - To do so from the file, open it and look for the key
react
in thedependencies
block. Once found, update the value to 16.8.5. Next, run the commandnpm install
at the project’s root directory. - You can update directly from the terminal by running the command
npm install react@16.8.5
at the project’s root directory. - To finally replace all files according to the new react-native version, run the command
react-native upgrade --legacy
at the project’s root directory, entering ‘y’ whenever a file replacement is prompted.
Note: In case you made changes in the AndroidManifest.xml
file, or any of the build.gradle
files, etc., these may have been restored to how they were before. You would have to make those changes again.