rnn-codebase

โดย wix

นำทางและทำงานกับโค้ดเบสของ react-native-navigation (RNN) ใช้เมื่อแก้ไขบั๊ก เพิ่มฟีเจอร์ ติดตามการไหลของคำสั่ง ทำความเข้าใจตัวเลือก…

npx skills add https://github.com/wix/react-native-navigation --skill rnn-codebase

React Native Navigation Codebase

Architecture Overview

RNN has three layers that mirror each other:

JS/TS (src/)  →  TurboModule bridge  →  iOS native (ios/)
                                     →  Android native (android/)

A navigation command (e.g. push) flows:

  1. Navigation.push()Commands.ts → processing pipeline → NativeCommandsSender.ts
  2. TurboModule: RNNTurboModule (iOS) / NavigationTurboModule.kt (Android)
  3. iOS: RNNCommandsHandlerRNNViewControllerFactory → UIKit controllers
  4. Android: NavigatorLayoutFactory → View-based controllers (no Fragments)

Read ARCHITECTURE.md for the full overview.

Key Cross-Layer Mappings

Layout Types → Native Controllers

JS Layout TypeiOS ControllerAndroid Controller
componentRNNComponentViewControllerComponentViewController
stackRNNStackController (UINavigationController)StackController
bottomTabsRNNBottomTabsController (UITabBarController)BottomTabsController
sideMenuRNNSideMenuViewController (MMDrawerController)SideMenuController (DrawerLayout)
topTabsRNNTopTabsViewControllerTopTabsController (ViewPager)
splitViewRNNSplitViewControllerN/A (iOS only)
externalComponentRNNExternalViewControllerExternalComponentViewController

Options → Presenters

Each controller type has a Presenter that applies options to views:

iOS ControlleriOS PresenterAndroid Presenter
RNNComponentViewControllerRNNComponentPresenterComponentPresenter
RNNStackControllerRNNStackPresenter + TopBarPresenterStackPresenter
RNNBottomTabsControllerRNNBottomTabsPresenterBottomTabsPresenter
RNNSideMenuViewControllerRNNSideMenuPresenterSideMenuPresenter

Events (same names both platforms)

EventTrigger
RNN.ComponentDidAppearScreen becomes visible
RNN.ComponentDidDisappearScreen hidden
RNN.NavigationButtonPressedTopBar button tap
RNN.BottomTabSelectedTab changed
RNN.ModalDismissedModal dismissed
RNN.ScreenPoppedScreen popped from stack
RNN.CommandCompletedAny command finished

Where to Find Things

By task: "I need to fix/change X"

TaskJS File(s)iOS File(s)Android File(s)
Command executionsrc/commands/Commands.tsios/RNNCommandsHandler.mmreact/NavigationTurboModule.kt
Layout creationsrc/commands/LayoutTreeParser.tsios/RNNViewControllerFactory.mmoptions/LayoutFactory.java
Options processingsrc/commands/OptionsProcessor.tsios/RNNNavigationOptions.mmoptions/Options.java
Options applicationios/*Presenter.mmviewcontrollers/*Presenter.java
TopBarsrc/interfaces/Options.ts (TopBarOptions)ios/TopBarPresenter.mm, ios/RNNUIBarButtonItem.mmviews/stack/topbar/
Bottom tabssrc/interfaces/Options.ts (BottomTabsOptions)ios/RNNBottomTabsPresenter.mmviewcontrollers/bottomtabs/
Modalssrc/commands/Commands.tsios/RNNModalManager.mmviewcontrollers/modal/ModalStack.java
Overlayssrc/commands/Commands.tsios/RNNOverlayManager.mmviewcontrollers/overlay/OverlayManager.kt
Animationssrc/interfaces/Options.ts (AnimationOptions)ios/ScreenAnimationController.mmviewcontrollers/stack/StackAnimator.kt
React view renderingios/RNNReactView.mmreact/ReactView.java
Events to JSsrc/adapters/NativeEventsReceiver.tsios/RNNEventEmitter.mmreact/events/EventEmitter.java
Component registrationsrc/components/ComponentRegistry.ts
Deep linking (URL → screen)src/linking/ (LinkingHandler, URLParser, RouteMatcher, DeferredLinkQueue, ModalLayoutBuilder)ios/RNNAppDelegate.mm (dispatchDeepLinkURL:, cold-start queue, RCTContentDidAppearNotification)NavigationActivity.onNewIntentReactGateway

By directory

  • src/ — JS public API, commands, processing pipeline. See src/ARCHITECTURE.md
  • ios/ — All Obj-C/C++ native code. See ios/ARCHITECTURE.md
  • ios/TurboModules/ — New architecture entry points (RNNTurboModule, RNNTurboManager, RNNTurboCommandsHandler)
  • android/src/main/java/com/reactnativenavigation/ — All Java/Kotlin native code. See android/ARCHITECTURE.md
  • playground/ — Demo app for development and E2E tests
  • playground/src/screens/ — Test screens exercising every feature
  • playground/e2e/ — Detox E2E tests

Options Resolution Order

Options are applied in ascending priority:

  1. Default options (from Navigation.setDefaultOptions()) — lowest priority
  2. Static options (from component class or Navigation.registerComponent)
  3. Options passed in the layout call (e.g. push, setRoot)
  4. mergeOptions() — runtime override, highest priority

JS Processing Pipeline (exact order)

API layout → OptionsCrawler.crawl() → LayoutProcessor.process()
  → LayoutTreeParser.parse() → LayoutTreeCrawler.crawl()
  → OptionsProcessor (colors, assets, custom) → NativeCommandsSender

iOS Patterns

  • All controllers conform to RNNLayoutProtocol
  • RNNBasePresenter subclasses apply options — applyOptionsOnInit:, applyOptions:, mergeOptions:resolvedOptions:
  • Commands run on main thread (RCTExecuteOnMainQueue)
  • React views: RNNReactView wraps RCTSurfaceHostingView (new arch)
  • Overlays use separate UIWindow instances (RNNOverlayWindow)
  • RNNReactComponentRegistry caches React component instances

Android Patterns

  • View-based, NOT Fragment-based
  • All commands dispatched via UiThread.post()
  • ViewController<T extends ViewGroup> is the base — createView() is abstract
  • ParentController extends ChildController extends ViewController
  • Bottom tabs use AHBottomNavigation library
  • Three root layouts in NavigationActivity: rootLayout, modalsLayout, overlaysLayout
  • Tab attachment modes: Together, OnSwitchToTab, AfterInitialTab

Development Workflow

Playground app

  • yarn start — Metro bundler
  • yarn xcode — Open iOS project
  • yarn studio — Open Android project
  • yarn pod-install — Install iOS pods

Testing

  • yarn test-js — Jest unit tests
  • yarn test-unit-ios — iOS native unit tests (XCTest)
  • yarn test-unit-android — Android native unit tests (JUnit + Robolectric)
  • yarn test-e2e-ios-ci / yarn test-e2e-android-ci — Detox E2E tests

Building

  • yarn prepare — Builds src/lib/ (ESM + types)
  • Codegen config: rnnavigation in package.json

Common Gotchas

  • iOS uses UIKit subclasses (UINavigationController, UITabBarController); Android uses custom View hierarchy
  • splitView is iOS-only
  • Side menu: iOS uses MMDrawerController (3rd party); Android uses DrawerLayout (native)
  • Options that exist in JS types may not be implemented on both platforms — check the presenter
  • passProps are stored in JS Store, not sent to native (cleared before bridge crossing)
  • The lib/ folder is generated — never edit it, edit src/ instead
  • Deep links are processed only after the first setRoot() resolves; pre-bridge URLs on iOS are queued natively in RNNAppDelegate and flushed on RCTContentDidAppearNotification (bridgeless mode — RCTJavaScriptDidLoadNotification does NOT fire)
  • ModalLayoutBuilder strips React-reserved keys (ref, key) from URL query params before they reach passProps, to avoid React 19 ref-validation crashes

Skills เพิ่มเติมจาก wix

wds-docs
wix
เอกสารอ้างอิงส่วนประกอบของระบบออกแบบ Wix ใช้เมื่อสร้าง UI ด้วย @wix/design-system เลือกส่วนประกอบ หรือตรวจสอบ props และตัวอย่าง ทำงานเมื่อ "อะไร…
official
wix-app
wix
สร้างและตรวจสอบส่วนขยายแอป Wix CLI — หน้าแดชบอร์ด, โมดอล, ปลั๊กอิน, ปลั๊กอินเมนู, วิดเจ็ตองค์ประกอบที่กำหนดเอง, คอมโพเนนต์ React ของ Editor, ปลั๊กอินไซต์,…
official
wix-cli-app-validation
wix
ใช้เมื่อทดสอบความพร้อมของแอป ตรวจสอบพฤติกรรมขณะรันไทม์ หรือตรวจสอบความถูกต้องก่อนการเผยแพร่และหลังการเปลี่ยนแปลงในโค้ด ทริกเกอร์รวมถึง validate, test,…
official
wix-cli-backend-api
wix
สร้าง HTTP endpoints สำหรับแอป Wix CLI ใช้เฉพาะเมื่อผู้ใช้ขอ backend endpoint โดยเฉพาะ ใช้เมื่อสร้าง REST API endpoints, backend HTTP…
official
wix-cli-backend-event
wix
สร้างส่วนขยายอีเวนต์แบ็กเอนด์ที่ตอบสนองต่ออีเวนต์ของ Wix ใช้เมื่อต้องการนำแฮนด์เลอร์ที่ทำงานเมื่อเงื่อนไขเฉพาะเกิดขึ้นบนไซต์ ทริกเกอร์รวมถึง…
official
wix-cli-context-provider
wix
สร้างส่วนขยายตัวให้บริบทสำหรับแอป Wix CLI — คอมโพเนนต์เชิงตรรกะ (ไม่มี UI) ที่เปิดเผยสถานะ ฟังก์ชัน และการกำหนดค่าที่ใช้ร่วมกันให้กับไซต์ย่อย…
official
wix-cli-dashboard-menu-plugin
wix
ต้องใช้เมื่อผู้ใช้ต้องการเพิ่มรายการเมนูที่คลิกได้ การดำเนินการ หรือตัวเลือกไปยังเมนูการดำเนินการเพิ่มเติม เมนูการดำเนินการแบบกลุ่ม หรือ... ของหน้าแดชบอร์ด Wix ที่มีอยู่
official
wix-cli-dashboard-modal
wix
ใช้เมื่อเพิ่มฟอร์มป๊อปอัป การยืนยัน หรือมุมมองรายละเอียดในแดชบอร์ดของ Wix; สร้างส่วนประกอบกล่องโต้ตอบที่ใช้ซ้ำได้ในหน้าแดชบอร์ด; แสดง…
official