How to easily upgrade React Native and the project dependencies.
There are several reasons why upgrading React Native to the latest version is beneficial:
Bug fixes and performance improvements: Each new version of React Native includes bug fixes and performance improvements, which can help to make your app run smoother and faster.
New features: Upgrading to the latest version of React Native can give you access to new features and functionality that may be useful for your app.
Security updates: Older versions of React Native may have security vulnerabilities that can be exploited by attackers. Upgrading to the latest version can help to mitigate these risks.
Compatibility with third-party libraries: As third-party libraries and dependencies are updated, they may require a newer version of React Native to work properly. Upgrading can ensure that your app remains compatible with these libraries.
Long-term support: As React Native continues to evolve, older versions may eventually lose support and become obsolete. Upgrading to the latest version can help to ensure that your app remains supported and maintained in the long term.
However, it's worth noting that upgrading to a new version of React Native can sometimes require changes to your code or dependencies, and may introduce new bugs or compatibility issues. It's important to carefully test and validate your app after upgrading to ensure that everything is working as expected.
How to Upgrade
You'll need to update a number of core dependencies. Updating React Native to 0.71.1 is the main change, but a number of other packages will need to be upgraded as well. While you can try to do this manually, there's a community maintained tool you can use to show you all of the outdated dependencies in your project:
npx @rnx-kit/align-deps --init
npx @rnx-kit/align-deps --requirements react-native@0.71Once you've update your core dependencies, you'll also need to make a number of changes in some supporting files in your project, such as the native project build files.
The best way to see the full list of changes needed is to use the React Native upgrade helper tool.
@react-native-community/async-storage is deprecated
ReplyDeleteAsync Storage has moved to new organization: https://github.com/react-native-async-storage/async-storage.
Use @react-native-async-storage/async-storage insted of @react-native-community/async-storage
@react-native-community/masked-view is deprecated
ReplyDeleteRepository was moved to @react-native-masked-view/masked-view.
Use@react-native-masked-view/masked-view insted of @react-native-community/masked-view
Issue -
ReplyDeleteViewPropTypes will be removed from React Native, along with all other PropTypes. We recommend that you migrate away from PropTypes and switch to a type system like TypeScript. If you need to continue using ViewPropTypes, migrate to the 'deprecated-react-native-prop-types' package.
Solution -
npm i deprecated-react-native-prop-types
Remove
import {ViewPropTypes} from ‘react-native’;
Add
import {ViewPropTypes} from 'deprecated-react-native-prop-types';