简体   繁体   English

升级 React Native 依赖项的最佳方法

[英]Best approach to upgrade react native dependencies

Recently, I joined a new company and found there are lots of outdated project dependencies eg react-navigation@2.xx, react-native-firebase, react-native etc. Now I want to upgrade all of them.最近入职了一家新公司,发现有很多过时的项目依赖,比如react-navigation@2.xx、react-native-firebase、react-native等,现在想全部升级。 Now another concern is rest of four developers are doing there on outdated packages.现在另一个问题是 rest 四位开发人员正在处理过时的软件包。

So what would be the best approaches那么最好的方法是什么

Thanks in advance提前致谢

I recently experienced the same thing.我最近经历了同样的事情。 And here's how i dealt with:这就是我的处理方式:

You must talk to those devs and get approval for upgrade.您必须与这些开发人员交谈并获得升级批准。 Then you must select a day with no development to upgrade because every new commit will introduce conflict, weekend would be best.然后你必须每天 select 没有开发升级,因为每次新提交都会引入冲突,周末最好。

Backup the project to multiple places, if you make something terrible, even remote git repo might not help you.将项目备份到多个地方,如果你做了一些糟糕的事情,即使是远程 git 仓库也可能帮不了你。

Upgrade react native first.先升级 React Native。 Recent versions of libraries depends on the new technologies of react native.最近版本的库依赖于 React Native 的新技术。 For example reanimated 2 requires rn > 0.62.例如 reanimated 2 需要 rn > 0.62。 You can use React Native Upgrade Helper to see what has changed.您可以使用React Native Upgrade Helper查看发生了什么变化。 If your project doesn't use too much custom native code you can even create a new empty react native project and copy necessary files.如果您的项目没有使用太多自定义原生代码,您甚至可以创建一个新的空 React Native 项目并复制必要的文件。

Test your app in android & ios to see upgrading react native didn't break anything.在 android 和 ios 中测试您的应用,看看升级 React Native 没有破坏任何东西。

Then look into every dependency to see what has changed.然后查看每个依赖项以查看发生了什么变化。 You're in luck if you can find a migration guide (something like this: https://reactnavigation.org/docs/5.x/upgrading-from-4.x ).如果您能找到迁移指南,那么您很幸运(类似这样的内容: https://reactnavigation.org/docs/5.x/upgrading-from-4.x )。 Some libraries like react navigation, react native reanimated changed drastically.一些库,如 react navigation,react native reanimated 发生了巨大变化。 These kind of libraries would be the most of your work, especially reanimated.这些类型的库将是您的大部分工作,尤其是重新激活的。 Test and backup project after every library.在每个库之后测试和备份项目。

And you should be done.你应该完成了。 Test your project again for every screen / every method.为每个屏幕/每个方法再次测试您的项目。 If you're 100% sure project is running as expected, you can change / create new tests and merge your changes.如果您 100% 确定项目按预期运行,您可以更改/创建新测试并合并您的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM