Upgrade React Native from 0.42 to 0.51

Upgrading React Native should be quite easy. But if you have an app that uses a very old version of React Native, things may be different. This post shows how to upgrade React Native from 0.42 to 0.51.

Update dependencies

React Native has an official guide on how to upgrade. I used a simpler approach, just remove ios and android directories, update dependencies in package.json and run react-native upgrade. It will recreate all platform files. The version of react-native is 0.51.0, while the version of react is 16.0.0.

Update PropTypes

React.PropTypes has been moved to a separate package prop-types. Need to import prop-types and change React.PropTypes to PropTypes.

Use Navigator

Navigator has been deprecated and moved to a separate package react-native-deprecated-custom-components. I don’t want to change the current usage of Navigator, so I just import Navigator from the new package. However, the current version 0.1.1 in npm has an issue with the usage of React.PropTypes. The current code in master branch fixed the issue but is not published to npm yet. I just cloned the repository and update the version using npm version patch and published it to my local npm registry. See this post on how to use your own private npm registry.

Comments