Labsco
wix logo

rnn-codebase

โ˜… 13,181

by wix ยท part of wix/react-native-navigation

Navigate and work with the react-native-navigation (RNN) codebase. Use when fixing bugs, adding features, tracing command flows, understanding options resolution, or working across JS/iOS/Android layers in this repo.

๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup
๐Ÿ”’ Repo-maintenance skill. It exists to help maintain wix/react-native-navigation itself โ€” it's only useful if you contribute code to that project.

This is the playbook your agent receives when the skill activates โ€” you don't need to read it to use the skill, but it's here to audit before installing.

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: RNNCommandsHandler โ†’ RNNViewControllerFactory โ†’ UIKit controllers
  4. Android: Navigator โ†’ LayoutFactory โ†’ 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 applicationโ€”ios/*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 renderingโ€”ios/RNNReactView.mmreact/ReactView.java
Events to JSsrc/adapters/NativeEventsReceiver.tsios/RNNEventEmitter.mmreact/events/EventEmitter.java
Component registrationsrc/components/ComponentRegistry.tsโ€”โ€”

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

Engine Integration (Wix One App)

RNN is a standalone library but also a core dependency of mobile-apps-engine (the Wix One App platform). Changes to RNN's public API surface can break engine.

Version Management

  • Version pinned in two files (must match):
    • packages/native/mobile-apps-engine-native/package.json
    • packages/wix-one-app-storage/package.json
  • yarn.config.cjs has a constraint that reads the version from mobile-apps-engine-native and validates all workspaces use the same version. It's a validation rule โ€” bumping the native package.json is sufficient.

iOS Integration

  • Engine's AppDelegate subclasses RNNAppDelegate โ€” breaking changes to that class will break engine.
  • Podfile resolves ReactNativeNavigation pod from node_modules.
  • Xcode project has header search paths pointing into node_modules/react-native-navigation/ios/**.

Android Integration

  • Engine's EngineRN.kt extends NavigationApplication and uses NavigationPackage / NavigationReactNativeHost.
  • missingDimensionStrategy "RNN.reactNativeVersion" is set in app/build.gradle โ€” may need updating if RNN changes its flavor dimensions.
  • Build variables RNNKotlinVersion, RNNKotlinStdlib, RNNKotlinCoroutinesCore are forwarded from engine's Kotlin config.

Active Patches (in engine's setup)

  • OptionsProcessor.js โ€” engine replaces RNN's OptionsProcessor.js at setup time via patchRNNOptionsProcessor() in packages/cli/mobile-apps-engine-setup/src/index.js. The patched copy lives at packages/cli/mobile-apps-engine-setup/etc/OptionsProcessor.js. It adds:
    • Custom iOS color processing with DynamicColorIOS (dark/light/dynamic object shapes)
    • Custom Android color processing wrapping colors in {dark, light} objects with semantic/resource_paths support
    • Component ID uses value.name instead of uniqueIdProvider.generate()
  • Any changes to src/commands/OptionsProcessor.ts require checking if the engine patch needs updating.

JS Wrappers

Engine wraps RNN's Navigation API in several services:

  • Navigator.ts โ€” root layout, overlays, error screens, tab navigation
  • BottomTabsBackHandler.ts โ€” back handling on bottom tabs via Navigation.events()
  • TabsManager.ts โ€” tab management using RNN Layout types
  • Various other services import Layout, LayoutRoot, LayoutSideMenu, OptionsSideMenu from RNN

Upgrade Checklist

  1. Bump version in both package.json files
  2. Verify OptionsProcessor.js patch still applies (diff upstream changes)
  3. Check RNNAppDelegate API compatibility (iOS)
  4. Check NavigationApplication / NavigationPackage / NavigationReactNativeHost API compatibility (Android)
  5. Verify missingDimensionStrategy value is still valid
  6. Check react-native-navigation-hooks and rnn-copilot compatibility
  7. Run yarn install to update lockfile
  8. Verify test mocks (react-native-navigation/Mock) still work

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