Thursday 4 April 2024

How to upgrade react native app (using React Native CLI)

Upgrading a React Native app involves updating the version of React Native and any dependencies, and then applying those updates to your native iOS/Android projects. 

Here's a step-by-step guide: 

 1. First, you need to check the latest version of React Native. You can do this by visiting the official React Native GitHub repository or by running the following command in your terminal:
npm info react-native
2. Once you know the latest version, you can update your package.json file to use this version. For example, if the latest version is 0.65.1, you would update your package.json like so:
"dependencies": {
  "react-native": "0.65.1"
}
3. After updating your package.json, you need to update your Node modules. You can do this by running the following command in your terminal:
npm install
4. Now that your Node modules are updated, you need to apply these updates to your native projects. React Native provides a command-line tool called react-native-upgrade that can help with this. You can use it by running the following commands in your terminal:
npx react-native upgrade
5. The upgrade command will apply the updates to your native projects. However, it might not be able to apply all updates automatically. In this case, you will need to apply these updates manually. The React Native upgrade helper (https://react-native-community.github.io/upgrade-helper/) can help you with this. It shows you the differences between your current version and the new version, and you can use this information to apply the necessary updates. 

 6. After applying all updates, you should test your app to make sure everything still works as expected.

 Remember to always backup your project before performing an upgrade. Upgrading can sometimes introduce breaking changes, and having a backup allows you to revert back if something goes wrong.

No comments:

Post a Comment