ReactNative0.75版本发布,一文快速了解

React Native 0.75 版本的更新包含了多个方面的内容,以下是一些详细信息:

亮点

  • Yoga 3.1和布局改进:支持%值在布局中的应用,如gap、translation等属性,但仅适用于新架构。
  • 新架构稳定化:修复了一些Bug,提高了稳定性,并在React Native Directory中添加了新架构支持信息,还发布了关于支持新架构中UIManager的文章。
  • 使用框架:推荐通过框架(如Expo)构建React Native应用,将/template文件夹移至单独的仓库,并计划在2024年12月31日停止使用react-native init命令,同时改进了自动链接的性能。
  1. Yoga 3.1 和布局改进
    • 支持 % 值:在布局中,gap(如columnGaprowGap)和translation属性现在支持使用%值。例如,可以在布局中使用<beginning of the code>rowGap: '20%'<end of the code>来设置行间距。
    • 仅适用于新架构:这些功能仅在新架构中可用,如果想要使用这些特性,需要考虑迁移到新架构。
  2. 新架构稳定化
    • 修复 Bug 和改进稳定性:自新架构在 React Conf 上宣布处于 Beta 阶段以来,发布了多个 Bug 修复和稳定性改进。
    • 解决的问题示例:修复了 Android 上的<beginning of the code>adjustsFontSizeToFit<end of the code>问题、<beginning of the code>textAlign<end of the code>在 Android 上与内联视图的兼容性问题以及 iOS 上的文本基线移动问题等。
    • React Native Directory 信息更新:与 Expo 合作,在 React Native Directory 中添加了关于新架构支持的信息,以便用户清楚了解某个库是否支持新架构。
    • 发布相关文章:发布了关于在新架构中支持UIManager的文章,提供了UIManager API 在 Android 上的概述以及它如何帮助更高级的应用和库进行迁移。
    • 新 API 访问<beginning of the code>jsi::Runtime<end of the code>:引入了新的 API 来安全地访问<beginning of the code>jsi::Runtime<end of the code>,在 iOS 上可以通过<beginning of the code>RCTTurboModuleWithJSIBindings<end of the code>协议实现,在 Android 上可以通过<beginning of the code>TurboModuleWithBindings<end of the code>接口实现。同时,在 UI 线程上可以使用<beginning of the code>CallInvoker<end of the code>来访问运行时。
  3. 使用框架
    • 推荐使用框架:如 Expo 等框架是构建 React Native 应用的推荐方式,使用框架可以提供更好的开发体验和更高的生产力。
    • 模板迁移:将<beginning of the code>/template<end of the code>文件夹从<beginning of the code>react-native<end of the code>包移动到了单独的仓库<beginning of the code>react-native-community/template<end of the code>,以便社区更方便地维护和演进模板。
    • 停止使用<beginning of the code>react-native init<end of the code>命令:从 2024 年 12 月 31 日起,将不再使用该命令创建项目,而是建议使用框架(如npx create - expo - app)或直接使用<beginning of the code>npx @react - native - community/cli init<end of the code>命令。
    • 自动链接性能改进:更新<beginning of the code>init<end of the code>命令时,重写了自动链接逻辑,提高了 Android 和 iOS 的构建速度。对于使用 Expo 的项目,Android 上的自动链接速度可提高约 6.5 倍,iOS 上可提高约 1.5 倍。

突破性变化

  • Touchables在TypeScript中的使用限制:TouchablesOpacity和TouchableHighlights组件不能再用作类型,应使用React.ElementRef或View类型。
  • 最低支持版本变更:0.75将是支持minSdk 23(Android 6.0)和minIOSVersion 13.4的最后一个版本,从0.76开始,minSdk版本将为24(Android 7.0),minIOSVersion将为15.1。
  • 其他变更:包括Android和iOS中一些API的删除、重命名以及功能的迁移等。

升级到0.75

使用React Native Upgrade Helper查看现有项目中React Native版本之间的代码更改,创建新项目的命令为npx @react-native-community/cli@latest init MyProject –-version latest,如果使用Expo,Expo SDK 51将支持React Native 0.75。

总结

总之,React Native 0.75在布局、架构稳定性、框架使用等方面进行了改进和优化,并对一些功能进行了调整和删除.

原文链接

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值