将本机升级到最新版本 [英] Upgrading react native to latest version

查看:71
本文介绍了将本机升级到最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 react-native 0.49.3 上运行的应用程序我想升级到最新版本 v0.57.4.

I have an application which runs on react-native 0.49.3 I want to upgrade to the latest version which is v0.57.4.

我应该逐步更新它吗?例如 0.49 -> 0.50 -> 0.51 等或者我可以将其更新到最新版本?

Should I incrementally update it? For example 0.49 -> 0.50 -> 0.51 etc Or I can just update it to to the latest version?

您建议使用 react-native-git-upgrade 还是 rn-diff?

Do you suggest using react-native-git-upgrade or rn-diff?

推荐答案

我的建议是升级到最新版本.无论如何都会有足够多的依赖问题,所以你最好只处理一次.

My advice is to upgrade to the latest version. There will be enough dependency issues anyway so you're best dealing with them only once.

来自 React Native 升级页面(https://facebook.github.io/react-native/docs/upgrading)

From the React Native upgrade page (https://facebook.github.io/react-native/docs/upgrading)

你可以运行:

npm install -g react-native-git-upgrade

npm install -g react-native-git-upgrade

react-native-git-upgrade

react-native-git-upgrade

更新:我以前从未遇到过升级问题,但最近在一个项目中,我们从 React Native 0.44.3 的旧副本升级到更新版本(首先到 0.57.8,然后到 0.55.4,然后到 0.58.3 在与稳定性作斗争的同时)并发现它并不总是像运行这些命令那么容易.请注意,这可能是一个漫长而乏味的过程,特别是如果您没有定期升级并且升级间隔很长.在这种情况下,是 18 个月.

UPDATE: I've never had a problem before with upgrades, but was recently on a project where we upgraded from an old copy of React Native 0.44.3 to a newer version (first to 0.57.8, then to 0.55.4, then to 0.58.3 while struggling with stability) and discovered that it's not always as easy as running those commands. Be warned that this could be a long, tedious process, especially if you have not upgraded regularly and have a long gap between upgrades. In this case, it was 18 months.

首先,升级过程本身(react-native upgrade,现在react-native-git-upgrade)本身发生了变化.因此,如果您使用的是一年或更长时间的版本,则您可能需要经历一些手动差异.有些是在运行 react-native-git-upgrade 命令后拼出来的,有些则不是.我很惊讶 Stack Overflow 上有多少人经历了看似无害的升级的相同未记录的循环问题.我没想到.我会接受 Facebook 在 6 个月内不添加任何功能并在继续之前简化升级过程.

First, there have been changes to the upgrade process itself (react-native upgrade, to now react-native-git-upgrade) itself. So, if you're using a version that's a year old or more there could be some manual discrepancies that you'll have to go through. Some are spelled out after running the react-native-git-upgrade command, and some are not. I was amazed at the number of people on Stack Overflow going through the same undocumented circular issues of a seemingly innocent upgrade. I was not expecting that. I'd be OK with Facebook not adding any features for 6 months and simplifying the upgrade process before moving on.

其次,确保您的 React Native 版本使用正确的依赖项.升级工具的更高版本 (react-native-git-upgrade) 尝试解决这个问题,但请仔细检查 https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md 查看版本您要升级到的 RN 需要特定的依赖项.有些会,有些则不会.

Second, make sure your version of React Native uses the right dependencies. Later versions of the upgrade tool (react-native-git-upgrade) try to account for this, but double check at https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md to see if the version of RN that you're upgrading to requires a specific dependency. Some do while others do not.

接下来,库 hades 是真实的,这取决于您的项目有多大.在我们的例子中,我们 0.44.3 版本中使用的几个模块现在已被弃用或不再维护,甚至与更高版本的 RN 的工作方式不同.在开始这个过程时,我没有考虑到这一点.这导致了几个代码重写实例只是为了升级!!哎呀!

Next, library hades is real, depending on how big your project is. In our case, several modules in use in our 0.44.3 version have now been deprecated or no longer maintained or even work differently with the later versions of RN. I didn't consider this enough when starting this process. This caused several instances of code rewrite just to upgrade!! Yikes!

此外,正如某些版本的 React Native 需要特定版本的依赖项一样,其他模块也需要某些依赖项的特定版本.更糟糕的是,有时这些是各种库的不兼容和冲突版本.节省一些时间并编写一两个用户故事来说明这一点.浏览您正在使用的每个模块,看看他们的 GitHub 页面上是否有任何兼容性声明.一些自述文件会告诉您将某些版本的模块与某些版本的 React Native 一起使用.其他人不会,您可能会在以后发现有要求.但即使经历了这个过程并预测了问题,你以后也会感谢自己.

Also, just as some versions of React Native require specific versions of dependencies, other modules require specific versions of some dependencies. Worse, sometimes these are incompatible and conflicting versions, of various libraries. Save some time and write a user story or two to account for this. Go through every module you're using and see if there are any compatibility statements on their GitHub page. Some Readme files will tell you to use certain versions of their module with certain versions of React Native. Others won't and you may find out later there are requirements. But even going through this process and anticipating issues, you'll thank yourself later.

更新并稳定后,请考虑定期升级,以尽量减少我刚刚经历的升级噩梦.

Once you're up to date and stable, consider upgrading regularly to minimize the upgrade nightmare that I just went through.

这篇关于将本机升级到最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆