Apéndice
Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →
I. Terminología
-
Spec - Código TypeScript o Flow que describe la API para un Turbo Native Module o componente nativo de Fabric. Utilizado por Codegen para generar código repetitivo.
-
Native Modules - Bibliotecas nativas sin Interfaz de Usuario (UI). Ejemplos: almacenamiento persistente, notificaciones, eventos de red. Accesibles desde tu código JavaScript como funciones y objetos.
-
Native Component - Vistas nativas de plataforma disponibles en tu código JavaScript mediante componentes de React.
-
Legacy Native Components - Componentes que funcionan en la antigua arquitectura de React Native.
-
Legacy Native Modules - Módulos que funcionan en la antigua arquitectura de React Native.
II. Tipos generados por Codegen
Puedes usar esta tabla como referencia para ver qué tipos son compatibles y su equivalente en cada plataforma:
| Flow | TypeScript | Flow Nullable Support | TypeScript Nullable Support | Android (Java) | iOS (ObjC) |
|---|---|---|---|---|---|
string | string | ?string | string | null | string | NSString |
boolean | boolean | ?boolean | boolean | null | Boolean | NSNumber |
Object Literal{| foo: string, ...|} | { foo: string, ...} as const | ?{| foo: string, ...|} | ?{ foo: string, ...} as const | - | - |
| Object [1] | Object [1] | ?Object | Object | null | ReadableMap | @ (untyped dictionary) |
Array<T> | Array<T> | ?Array<T> | Array<T> | null | ReadableArray | NSArray (or RCTConvertVecToArray when used inside objects) |
Function | Function | ?Function | Function | null | - | - |
Promise<T> | Promise<T> | ?Promise<T> | Promise<T> | null | com.facebook.react.bridge.Promise | RCTPromiseResolve and RCTPromiseRejectBlock |
Type Unions'SUCCESS'|'FAIL' | Type Unions'SUCCESS'|'FAIL' | Only as callbacks | - | - | |
Callbacks() => | Callbacks() => | Yes | com.facebook.react.bridge.Callback | RCTResponseSenderBlock | |
number | number | No | double | NSNumber |
Notas:
[1] We strongly recommend using Object literals instead of Objects.
También puede resultarte útil consultar las especificaciones JavaScript de los módulos principales de React Native. Se encuentran en el directorio Libraries/ del repositorio de React Native.