
rnn-codebase
โ 13,181by 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.
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:
Navigation.push()โCommands.tsโ processing pipeline โNativeCommandsSender.ts- TurboModule:
RNNTurboModule(iOS) /NavigationTurboModule.kt(Android) - iOS:
RNNCommandsHandlerโRNNViewControllerFactoryโ UIKit controllers - 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 Type | iOS Controller | Android Controller |
|---|---|---|
component | RNNComponentViewController | ComponentViewController |
stack | RNNStackController (UINavigationController) | StackController |
bottomTabs | RNNBottomTabsController (UITabBarController) | BottomTabsController |
sideMenu | RNNSideMenuViewController (MMDrawerController) | SideMenuController (DrawerLayout) |
topTabs | RNNTopTabsViewController | TopTabsController (ViewPager) |
splitView | RNNSplitViewController | N/A (iOS only) |
externalComponent | RNNExternalViewController | ExternalComponentViewController |
Options โ Presenters
Each controller type has a Presenter that applies options to views:
| iOS Controller | iOS Presenter | Android Presenter |
|---|---|---|
RNNComponentViewController | RNNComponentPresenter | ComponentPresenter |
RNNStackController | RNNStackPresenter + TopBarPresenter | StackPresenter |
RNNBottomTabsController | RNNBottomTabsPresenter | BottomTabsPresenter |
RNNSideMenuViewController | RNNSideMenuPresenter | SideMenuPresenter |
Events (same names both platforms)
| Event | Trigger |
|---|---|
RNN.ComponentDidAppear | Screen becomes visible |
RNN.ComponentDidDisappear | Screen hidden |
RNN.NavigationButtonPressed | TopBar button tap |
RNN.BottomTabSelected | Tab changed |
RNN.ModalDismissed | Modal dismissed |
RNN.ScreenPopped | Screen popped from stack |
RNN.CommandCompleted | Any command finished |
Where to Find Things
By task: "I need to fix/change X"
| Task | JS File(s) | iOS File(s) | Android File(s) |
|---|---|---|---|
| Command execution | src/commands/Commands.ts | ios/RNNCommandsHandler.mm | react/NavigationTurboModule.kt |
| Layout creation | src/commands/LayoutTreeParser.ts | ios/RNNViewControllerFactory.mm | options/LayoutFactory.java |
| Options processing | src/commands/OptionsProcessor.ts | ios/RNNNavigationOptions.mm | options/Options.java |
| Options application | โ | ios/*Presenter.mm | viewcontrollers/*Presenter.java |
| TopBar | src/interfaces/Options.ts (TopBarOptions) | ios/TopBarPresenter.mm, ios/RNNUIBarButtonItem.mm | views/stack/topbar/ |
| Bottom tabs | src/interfaces/Options.ts (BottomTabsOptions) | ios/RNNBottomTabsPresenter.mm | viewcontrollers/bottomtabs/ |
| Modals | src/commands/Commands.ts | ios/RNNModalManager.mm | viewcontrollers/modal/ModalStack.java |
| Overlays | src/commands/Commands.ts | ios/RNNOverlayManager.mm | viewcontrollers/overlay/OverlayManager.kt |
| Animations | src/interfaces/Options.ts (AnimationOptions) | ios/ScreenAnimationController.mm | viewcontrollers/stack/StackAnimator.kt |
| React view rendering | โ | ios/RNNReactView.mm | react/ReactView.java |
| Events to JS | src/adapters/NativeEventsReceiver.ts | ios/RNNEventEmitter.mm | react/events/EventEmitter.java |
| Component registration | src/components/ComponentRegistry.ts | โ | โ |
By directory
src/โ JS public API, commands, processing pipeline. See src/ARCHITECTURE.mdios/โ All Obj-C/C++ native code. See ios/ARCHITECTURE.mdios/TurboModules/โ New architecture entry points (RNNTurboModule,RNNTurboManager,RNNTurboCommandsHandler)android/src/main/java/com/reactnativenavigation/โ All Java/Kotlin native code. See android/ARCHITECTURE.mdplayground/โ Demo app for development and E2E testsplayground/src/screens/โ Test screens exercising every featureplayground/e2e/โ Detox E2E tests
Options Resolution Order
Options are applied in ascending priority:
- Default options (from
Navigation.setDefaultOptions()) โ lowest priority - Static options (from component class or
Navigation.registerComponent) - Options passed in the layout call (e.g.
push,setRoot) mergeOptions()โ runtime override, highest priority
JS Processing Pipeline (exact order)
API layout โ OptionsCrawler.crawl() โ LayoutProcessor.process()
โ LayoutTreeParser.parse() โ LayoutTreeCrawler.crawl()
โ OptionsProcessor (colors, assets, custom) โ NativeCommandsSenderiOS Patterns
- All controllers conform to
RNNLayoutProtocol RNNBasePresentersubclasses apply options โapplyOptionsOnInit:,applyOptions:,mergeOptions:resolvedOptions:- Commands run on main thread (
RCTExecuteOnMainQueue) - React views:
RNNReactViewwrapsRCTSurfaceHostingView(new arch) - Overlays use separate
UIWindowinstances (RNNOverlayWindow) RNNReactComponentRegistrycaches 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 abstractParentControllerextendsChildControllerextendsViewController- Bottom tabs use
AHBottomNavigationlibrary - Three root layouts in
NavigationActivity: rootLayout, modalsLayout, overlaysLayout - Tab attachment modes:
Together,OnSwitchToTab,AfterInitialTab
Development Workflow
Playground app
yarn startโ Metro bundleryarn xcodeโ Open iOS projectyarn studioโ Open Android projectyarn pod-installโ Install iOS pods
Testing
yarn test-jsโ Jest unit testsyarn 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โ Buildssrc/โlib/(ESM + types)- Codegen config:
rnnavigationinpackage.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.jsonpackages/wix-one-app-storage/package.json
yarn.config.cjshas a constraint that reads the version frommobile-apps-engine-nativeand validates all workspaces use the same version. It's a validation rule โ bumping the native package.json is sufficient.
iOS Integration
- Engine's
AppDelegatesubclassesRNNAppDelegateโ breaking changes to that class will break engine. - Podfile resolves
ReactNativeNavigationpod from node_modules. - Xcode project has header search paths pointing into
node_modules/react-native-navigation/ios/**.
Android Integration
- Engine's
EngineRN.ktextendsNavigationApplicationand usesNavigationPackage/NavigationReactNativeHost. missingDimensionStrategy "RNN.reactNativeVersion"is set inapp/build.gradleโ may need updating if RNN changes its flavor dimensions.- Build variables
RNNKotlinVersion,RNNKotlinStdlib,RNNKotlinCoroutinesCoreare forwarded from engine's Kotlin config.
Active Patches (in engine's setup)
- OptionsProcessor.js โ engine replaces RNN's
OptionsProcessor.jsat setup time viapatchRNNOptionsProcessor()inpackages/cli/mobile-apps-engine-setup/src/index.js. The patched copy lives atpackages/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 withsemantic/resource_pathssupport - Component ID uses
value.nameinstead ofuniqueIdProvider.generate()
- Custom iOS color processing with
- Any changes to
src/commands/OptionsProcessor.tsrequire 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 navigationBottomTabsBackHandler.tsโ back handling on bottom tabs viaNavigation.events()TabsManager.tsโ tab management using RNNLayouttypes- Various other services import
Layout,LayoutRoot,LayoutSideMenu,OptionsSideMenufrom RNN
Upgrade Checklist
- Bump version in both
package.jsonfiles - Verify
OptionsProcessor.jspatch still applies (diff upstream changes) - Check
RNNAppDelegateAPI compatibility (iOS) - Check
NavigationApplication/NavigationPackage/NavigationReactNativeHostAPI compatibility (Android) - Verify
missingDimensionStrategyvalue is still valid - Check
react-native-navigation-hooksandrnn-copilotcompatibility - Run
yarn installto update lockfile - Verify test mocks (
react-native-navigation/Mock) still work
Common Gotchas
- iOS uses UIKit subclasses (UINavigationController, UITabBarController); Android uses custom View hierarchy
splitViewis 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
passPropsare stored in JSStore, not sent to native (cleared before bridge crossing)- The
lib/folder is generated โ never edit it, editsrc/instead
npx skills add wix/react-native-navigation --skill "rnn-codebase" --full-depthRun this in your project โ your agent picks the skill up automatically.
No common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.
Licensed under MITโ you can use, modify, and redistribute it under that license's terms.
View the full license file on GitHub โ