This article will guide you through the process of upgrading your React native version from a lower version possibly less than 0.59 to 0.62
Tl;dr: it's a cumbersome process if you don't follow it correctly.
Why upgrade to newer versions of React Native? 🙄
Major reasons for upgrading to React Native v0.62.2
- Speed boost! ✔
- Fast refresh / live-reload ⚡
- Hermes support (compiles the js code to binary, which helps in less startup time, faster response, and smaller app size)
- First-class support for flipper (an awesome debugging tool for react-native)
- Support for React hooks 🙌
- Other Bug fixes. 🐞
Well, the newer versions of React native ( >0.60) has a utility tool to upgrade easily. It uses git under the hood to upgrade your React native under the hood. But coming to older versions of react-native (<0.60) this support doesn't work quite well. And in most cases, it requires you to manually upgrade.
So, to upgrade from 0.57.0 to 0.62.2 you need to first upgrade it to 0.58.6 and then 0.59.10 after this you're okay to upgrade to 0.62 or higher. This is my personal experience. Because jumping directly to the latest version had many confusions and thus failures. So, I recommend upgrading it in parts.
Here's the actual upgrade process of React native from 0.57.0 to 0.62.2
- Delete your node_modules folder
- Go to this page and select your current version and the target version (increase each version at a time)
- Click "Show me how to upgrade" button
- Now scroll down and manually check the changes shown in the diff.
- Try to replicate the same in your code
- Now install all the packages using yarn install or npm i
- Clean the project using gradlew clean
- Do a build either by yarn android or android studio.
- If the build is successful try to run the app in your device else there's a problem with the changed files, check diff again and repeat the steps 1 to 8.
That's it. You now have the latest React Native version. You've successfully upgraded from 0.57.0 to 0.62.2 🎉
Let me know if you face any problems or if you have any better ways to do it. 😊