新架构的两大支柱
这个文档仍然是实验性的,随着我们的迭代,细节会有变化。欢迎在工作小组内的讨论中分享你的反馈。
此外,它还包含几个手动步骤。请注意新架构尚未稳定下来,最终的开发者体验会继续迭代改善。我们正在努力开发工具、模板和库,以帮助你在新架构上快速入门,而不需要经历整个设置过程。
新架构主要由两大支柱组成:
TurboModules are the preferred way to create libraries that leverage some platform specific API. Fabric Components are the preferred way to create reusable UI components, providing a native experience to the users.
The main goal of this section is to drive the reader through a step-by-step guide to create their first TurboModule or Fabric Component.
The next sections contain an high-level overview of the pillars, together with the steps to create them. To create one of these pillars, the steps are:
- Define a JavaScript specification using Flow or TypeScript.
- Configure the dependencies management system to generate code from the provided spec.
- Implement the Native code.
- Integrate the code in the app.
Finally, we dive a little deeper into the Codegen process that is required to create all the C++ types and files used by our components, including some useful steps to work comfortably while developing the component.
To integrate a TurboModule or a Fabric Component in an app, the app has to run with the New Architecture enabled.
To create a new app adopting the New Architecture, refer to the Using the App Template section. To migrate an existing app to the New Architecture, refer to the Migration guide.