I saw some extremely frustrating Reddit threads discussing about why it is so difficult to upgrade to the latest React Native version. I was at this sorry state because I was upgrading it incorrectly!
Recently, I was given a task to upgrade an Expo managed React Native mobile application to the latest version, i.e., Expo version 50.0.0.
Table of Contents
If you also use an Expo managed project, here are the two most important things that you need to keep in mind:
1. Always upgrade one version at a time
Upgrading one version at a time is extremely important as even Expo has recommended the developers to do so in their upgrade documentation.
I was trying to upgrade from Expo v47 to v50 in one go!
That caused a lot of issues and much of my effort got wasted. It is easier to less errors by upgrading to v48 instead of resolving huge number of errors by upgrading to v50 directly.
2. If you use a development build, create a new development build after each version upgrade
When I was first trying to upgrade, I didn’t follow this step. That resulted errors getting logged in on big red screens on my Android Studio virtual device.
Expo changelog documentation of v50 has mentioned this.
Now, here are the steps that you need to follow to upgrade to latest Expo/React Native versions.
Upgrade to Latest Expo Version
1. Open the documentation on Upgrade Expo SDK and read it first!
You will surely find some important information there.
2. Upgrade Expo version
Here, I am upgrading to v50
yarn add expo@50.0.0
3. Upgrade all dependencies to match the installed SDK version.
This will help upgrade all the dependencies of the project and make them compatible with the current Expo SDK version.
npx expo install –fix
4. Create a new development build (new apk file)
I used a development build in my project, so I had to create new development build to test my application.
eas build --platform android --profile development
5. Run development server
Check and see if the app is running correctly and has no errors.
npx expo start --dev-client
6. Build the application
If the application runs correctly, create a new production build.
eas build --platform android
7. Submit the application to Play Store
If the build is successful, initiate a new submission of your app to Google Play Store.
eas submit --platform android
There you go! You have successfully upgraded the Expo and React Native versions of your project.
Important Note
Even if the steps are written here, it might not be a smooth sail to upgrade the Expo version of your application. You will encounter errors and warnings. The key is to research those on the internet by checking GitHub issues of those packages and checking going through discussions on StackOverflow.
Read more: How to Create Toggle Password Visibility with Material UI