React Native Blog Dec 5, 2016

Easier Upgrades

Article Summary

React Native upgrades used to be a nightmare of merge conflicts and lost changes. The React Native team just changed that with a clever Git-based solution.

The React Native team introduced react-native-git-upgrade, a new tool that automates the painful process of upgrading React Native versions. Instead of manually resolving conflicts or losing local changes, the tool leverages Git's 3-way merge algorithm to handle upgrades intelligently.

Key Takeaways

Critical Insight

React Native upgrades now use Git's merge algorithm to automatically resolve conflicts and preserve your customizations, turning a dreaded multi-hour task into a single command.

The technical implementation reveals why this had to be a separate global package rather than built into React Native itself.

About This Article

Problem

React Native upgrades put developers in a bind. They could overwrite their local changes to get critical updates, or skip the upgrade and keep their customizations. There was no way to do both.

Solution

The React Native team worked with Zenika and M6 Web to create react-native-git-upgrade. It compares old and new project templates to generate Git patches, then uses Git's 3-way merge algorithm to resolve conflicts automatically.

Impact

The tool works with any React Native version and doesn't need npm install to run first. It removes the need for manual react-native link commands after upgrades because it preserves Android and iOS build files automatically.