Skip to main content

부록

I. 용어 정리

  • Spec - Turbo Native Module이나 Fabric Native 컴포넌트의 API를 정의하는 TypeScript 또는 Flow 코드. Codegen이 이 Spec을 기반으로 보일러플레이트 코드를 생성한다.

  • Native Modules - 사용자 인터페이스(UI)가 없는 네이티브 라이브러리. 예를 들어, 영구 저장소, 알림, 네트워크 이벤트 등이 이에 해당한다. JavaScript 애플리케이션 코드에서 함수와 객체로 접근할 수 있다.

  • Native Component - React Components를 통해 JavaScript 애플리케이션 코드에서 사용할 수 있는 네이티브 플랫폼 뷰.

  • Legacy Native Components - 이전 React Native 아키텍처에서 동작하는 컴포넌트.

  • Legacy Native Modules - 이전 React Native 아키텍처에서 동작하는 모듈.

II. 코드 생성 타입 매핑

다음 표는 각 플랫폼에서 지원되는 타입과 그에 대응하는 매핑을 참조할 수 있다:

FlowTypeScriptFlow Nullable SupportTypeScript Nullable SupportAndroid (Java)iOS (ObjC)
stringstring?stringstring | nullstringNSString
booleanboolean?booleanboolean | nullBooleanNSNumber
Object Literal
{| foo: string, ...|}
{ foo: string, ...} as const?{| foo: string, ...|}?{ foo: string, ...} as const--
Object [1]Object [1]?ObjectObject | nullReadableMap@ (untyped dictionary)
Array<T>Array<T>?Array<T>Array<T> | nullReadableArrayNSArray (or RCTConvertVecToArray when used inside objects)
FunctionFunction?FunctionFunction | null--
Promise<T>Promise<T>?Promise<T>Promise<T> | nullcom.facebook.react.bridge.PromiseRCTPromiseResolve and RCTPromiseRejectBlock
Type Unions
'SUCCESS'|'FAIL'
Type Unions
'SUCCESS'|'FAIL'
Only as callbacks--
Callbacks
() =>
Callbacks
() =>
Yescom.facebook.react.bridge.CallbackRCTResponseSenderBlock
numbernumberNodoubleNSNumber

참고 사항:

[1] 객체(Object) 대신 객체 리터럴(Object literals)을 사용하는 것을 강력히 권장한다.

info

React Native의 코어 모듈에 대한 JavaScript 명세를 참조하는 것도 유용할 수 있다. 이 명세는 React Native 저장소의 Libraries/ 디렉토리 내에 위치한다.