Skip to main content

什么是向后兼容性


提醒

本文档仍为 experimental,详细信息可能会随着我们的迭代而发生变化。 欢迎在此页面分享你对 工作组内部讨论 的反馈。

This documentation is still experimental and details are subject to changes as we iterate. Feel free to share your feedback on the discussion inside the working group for this page.

而且,它还包含几个 手动步骤。 请注意,一旦新架构稳定,这将不代表最终的开发者体验。 我们正在开发工具、模板和库,以帮助你快速开始使用新架构,而无需完成整个设置。

Moreover, it contains several manual steps. Please note that this won't be representative of the final developer experience once the New Architecture is stable. We're working on tools, templates and libraries to help you get started fast on the New Architecture, without having to go through the whole setup.

创建向后兼容的模块对于提供可在 旧架构新架构 中工作的库非常重要。 并非你库的所有用户都会立即跳上新架构的船: 即使他们仍在使用旧的架构,他们也能够使用你的库,这是一件好事。

Creating a backward compatible module is important to provide a library that works in both the Old Architecture and the New Architecture. Not all the users of your library will immediately jump on the New Architecture ship: it is a good thing that they will be able to use your library even if they are still using the old architecture.

创建良好的向后兼容模块的技巧是尽量减少采用新版本所需的更改。 这样,模块的用户可以顺利地迁移到新版本,并在准备好时迁移到新架构,最好是通过发出一个不同的命令。

The trick to create a good backward compatible module is to minimize the changes required to adopt the new version. In that way, users of the module can smoothly move to the new version and migrate to the New Architecture when they are ready, ideally by issuing one different command.

为了实现这一结果,我们必须对 Turbo Native 模块Fabric 原生组件 配置进行一些更改。 我们必须遵循的步骤是:

To achieve this result, we have to perform few changes in our Turbo Native Module and Fabric Native Component configurations. The steps we have to follow are:

  1. 更新安装配置 避免使用旧架构不需要的代码。
  2. 更新代码 支持两种架构。 Android 和 iOS 构建管道都为你提供了提供库的机制,该库将使用正确的 React Native 架构进行编译。
  3. 配置规范以加载正确的实现,以便 JavaScript 层在新架构可用时利用它。
信息

接下来的部分要求你熟悉 Pillars新架构

  • 要创建向后兼容的 Turbo Native 模块,请遵循 本指南
  • 要创建向后兼容的 Fabric 原生组件,请遵循 本指南