Upgrade your app to the latest version to get more features and better support.
The following article is a part of The Ultimate Guide to React Native Optimization and describes how important it is to always use the latest version of Rect Native while developing apps.
Why is it important?
The mobile app market is dynamic and if you want to keep your users satisfied, you have to pay attention to the latest upgrades for your products. This applies to both libraries and framework used in your app. Staying up to date with your products will not only improve their performance or security. They will also adjust your app to the latest underlying changes in iOS and Android. It gives you the confidence that users will be able to run your apps on every device with no crashes. In this article, you’ll find out why upgrading to the latest React Native version is a good idea, how to do it and what kind of benefits it brings for you and your users.
In the previous parts of our guide, we have discussed:
- Reducing the device’s battery usage with UI re-renders
- The best practices around using dedicated higher-ordered React Native components
- Picking external libraries
- Libraries optimized for mobile
- How to achieve 60FPS animations in React Native
Be sure, to check them out.
Now, let’s move to our main topic.
Always run the latest React Native version to access the new features
Issue: You are running an old and unsupported version of React Native and depriving yourself from new improvements and features
React Native is one of these libraries that is growing in a very rapid way.
Every day, developers from all around the world introduce new features, critical bug fixes and security patches. On average, each release includes around 500 commits. Most popular changes among the community include features such as Fast Refresh or Autolinking – both of them we describe in the following sections.
In the React Native ecosystem it’s common that libraries are not backwards-compatible. New features often use goodies not available in the previous versions of the framework. It means that if your application runs on an older React Native version, you are eventually going to start missing out on the latest improvements.
That’s why, keeping up with the newest React Native upgrades may seem like the only way to go.
Unfortunately, there is some serious work associated with upgrading your React Native code with every new release. Its amount will depend on the number of underlying changes to the native functionalities and core pieces. Most of the time, you have to carefully analyze and compare your project against the latest version and make the adjustments on your own. This task is easier if you’re already comfortable with moving around the native environment. But if you’re like most of us, it might be a bit more challenging.
For instance, it may turn out that the modules and components you used in your code are no longer the part of the react-native core.
It would be because of the changes introduced by Facebook during a process called the lean core. The goals of the effort were to:
- Make react-native package smaller, more flexible and easier to maintain by extracting some parts of the core and moving them to react-native-community repository,
- Transfer the maintenance of the extracted modules to the community.
The process accelerated the growth of particular modules and made the whole ecosystem better organized. But it also had some negative effect on a react-native-upgrade. Now, you have to install the extracted packages as an additional dependency and until you do it, your app will not compile or crash at runtime. However, from a developer’s perspective, migration to community packages is usually nothing more than introducing a new dependency and rewriting imports.
Another important issue is the third-parties support. Your code usually relies on external libraries and there’s a risk that they also might be incompatible with the latest React Native version.
There are at least two ways to solve this problem:
- Wait for the project maintainers to perform necessary adjustments before you upgrade,
- Look for the alternatives or patch the modules yourself – by using a handy utility called patch-package or creating a temporary fork with necessary fixes.
Running on an old version means shipping with issues that may discourage your users
If you are running on an older version, it is likely that you are lagging behind your competition that uses the latest versions of the framework.
The number of fixes, improvements and advancements in the React Native framework is really impressive. If you’re playing the catch-up game, you opt out from a lot of updates that would make your life a lot easier. The workload and the cost involved in making regular upgrades are always offset by the immediate DX (developer experience) enhancements.
In this section, we present some of the well-established practices to ease upgrading React Native to the newer version.
Solution: Upgrade to latest React Native version (we’ll show you how)
Upgrading React Native might be not the easiest thing in the world. But there are tools that make this process much simpler and take most of the problems away. The actual amount of work will depend on the number of changes and your base version. However, the steps presented in this section can be applied to every upgrade, regardless of the state of your application.
Preparing for the upgrade
React Native Upgrade Helper is a good place to start. On a high level, it gives you an overview of the changes that happened to React Native since the last time you have upgraded your local version.
package.json between React Native 0.59 and React Native 0.60
To do so, the helper compares bare React Native projects created by running
npx react-native init with your version and the one you’re upgrading to. Next, it shows the differences between the projects, making you aware of every little modification that took place in the meantime. Some changes may be additionally annotated with a special information that will give more context on why something has happened.
Additional explanation of more interesting changes to user files
Having a better overview of the changes will help you move faster and act with more confidence.
Note: Having more context is really important as there is no automation in place when it comes to upgrading – you will have to apply the changes yourself.
React Native Upgrade Helper also suggests useful content to read while upgrading. That in most cases includes a dedicated blog post published on React Native blog as well as the raw changelog.
Useful content to read while upgrading to React Native 0.60
We advise you to read the recommended resources to get a better grip on the upcoming release and learn about its highlights.
Thanks to that, you will not only be aware of the changes, but you will also understand the reasoning behind them. And you will be ready to open up your project and start working on it.
The first step is to bump the React and React Native dependencies to the desired versions and perform necessary changes (including breaking changes). To do so, you can look up the suggestions provided by React Native Upgrade Helper and apply them manually. Once it’s completed, make sure to reinstall your
Note: When performing the upgrade, you may see a lot of changes coming from iOS project files (everything inside .xcodeproj, including .pbxproj). These are files generated by Xcode as you work with your iOS part of React Native application.
Instead of modifying the source file, it is better to perform the changes via the Xcode UI. This was the case with upgrading to React Native 0.60 and the appropriate operations were described in this issue.
Finally, you should try running the application. If everything is working – perfect. The upgrade was smooth and you can call it a day! On a more serious note though – now you should check if there are newer versions of other dependencies you use! They may be shipping important performance improvements.
Unfortunately, there’s also another, a bit more pessimistic scenario. Your app may not build at all or may instantly crash with a red screen. In that case, it is very likely that some of your third-party dependencies are not working properly and you need to make them compatible with your React Native version.
Note: If you have a problem with your upgrades, you can check the Upgrade Support project. It is a repository where developers share their experience and help each other solve some of the most challenging operations related to upgrading.
Upgrading third-party libraries
If the error occurs during the build time, simply bumping the dependency to its latest version should make it work.
As you can see, there is no magic trick that would fix all the errors and upgrade the dependencies automatically. This is mostly a manual work that has to be done with patience and attention. It also requires a lot of testing to ensure that you didn’t break any features along the way.
Benefit: You’re running latest versions which translates to more features and better support
Upgrading to the latest React Native version shouldn’t be different from keeping your other frameworks and libraries up to date. Apart from critical performance and security improvements, new React Native releases also addresses the latest underlying changes to the iOS and Android. That includes the breaking changes that apply to mobile phones, such as when certain APIs get deprecated.
Here is an example: Last year, Google has announced that all Android applications submitted to Google Play after August 1, 2019 have to be 64-bit. In order to continue developing your application and shipping new features, you had to upgrade to React Native 0.59 and perform necessary adjustments.
Upgrades like this are really critical to keeping your users satisfied. After all, they would be disappointed if the app started to crash with the newer version of the operating system or disappeared from the App Store. There might be some additional workload associated with every release, but staying up to date will pay back with happier users, more stable app and better development experience.
To put things together, upgrading React Native to its latest version improves not only the performance and security of your apps but also adjusts your apps to the changes in iOS and Android. Thanks to that, your users are able to enjoy the apps fully compatible with the latest version of their mobile software.
In the next article, we will share with you some tips on how to debug faster with Flipper.
We are the official Facebook partners on React Native. We’ve been working on React Native projects for over 5 years, delivering high-quality solutions for our clients and contributing greatly to the React Native ecosystem. Our Open Source projects help thousands of developers to cope with their challenges and make their work easier every day.
Contact us if you need help with cross-platform or React Native development. We will be happy to provide a free consultation.