feat:migrate to standard navigation shared adapter - #581
oleksandrzavarzin-callstack wants to merge 15 commits into
Conversation
| @@ -0,0 +1,12 @@ | |||
| --- | |||
| '@bottom-tabs/navigation': minor | |||
There was a problem hiding this comment.
Let's call this new package @bottom-tabs/standard-navigation to keep consistency with React Navigation
| `NativeBottomTabsContent` carries its event map and navigator props on phantom properties, so an integrator can type `tabBarActiveTintColor`, `tabBar` and the rest. Neither is inferable from the contract on its own - the event map appears only as an argument to `emitter.emit`, and the navigator props only inside an `Omit<…>`. | ||
|
|
||
| `createNativeBottomTabNavigator` renders through the shared navigator, and keeps building its own state with `useNavigationBuilder`, so `state.key` and the per-route `navigation` and `route` objects a custom `tabBar` reads stay intact. | ||
|
|
||
| `@bottom-tabs/react-navigation` now requires `@react-navigation/native` 7.3.0 or newer, which is the version that introduced `createStandardNavigationFactories` used by the documented shared-navigator recipe |
There was a problem hiding this comment.
All of this is unnecessary for the changeset
Match the naming of @bottom-tabs/react-navigation, and trim the changeset down to the release-note facts. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| <PackageManagerTabs command="install react-native-bottom-tabs" /> | ||
|
|
||
| If you are going to use [React Navigation / Expo Router Integration](/docs/guides/usage-with-react-navigation) make sure to install `@bottom-tabs/react-navigation`. | ||
| If you are going to use the [React Navigation integration](/docs/guides/usage-with-react-navigation), also install `@bottom-tabs/react-navigation`. |
There was a problem hiding this comment.
Shouldn't it be here React Navigation or Expo SDK < 56? Or I'm missing something?
There was a problem hiding this comment.
Yep, that's true.
I've added "Expo SDK 55+" note to it.
| @@ -0,0 +1,116 @@ | |||
| import { NavigationContainer } from '@react-navigation/native'; | |||
There was a problem hiding this comment.
Not related to this file specifically, but the example app should be named example-expo-router to follow the convention of the other example apps
There was a problem hiding this comment.
It's a test harness rather than the example Expo router app (for that option, we will have expo-template, after it's updated). It just checks whether our two adapters, driven by a real Expo Router and a real React Navigation, pass the same correct props to the tab view.
| | 55 and older | `@bottom-tabs/react-navigation` | `withLayoutContext` | | ||
|
|
||
| Next, create a custom layout adapter for the native bottom tabs using `withLayoutContext` from Expo Router. Put it in `components/bottom-tabs.tsx` and export the navigator, so your layouts can import it: | ||
| ## Expo SDK 56 and newer |
There was a problem hiding this comment.
Hard to see in the diff, but did we loose the section for integrating with SDK < 56?
It's important to have it since we still support it with the old integration
There was a problem hiding this comment.
Here is that section:
react-native-bottom-tabs/docs/docs/docs/guides/usage-with-expo-router.mdx
Lines 85 to 124 in a65309c
What
Expo SDK 56 dropped Expo Router's dependency on
@react-navigation/*in favour of a vendored fork.@bottom-tabs/react-navigationimports the real thing, so on SDK 56+ two copies of React Navigation load and their contexts stop lining up.This moves the tab view into a new framework-agnostic package,
@bottom-tabs/standard-navigation, built on thestandard-navigationcontract. One implementation, two adapters:@bottom-tabs/standard-navigationunstable_createStandardRouterNavigator@bottom-tabs/react-navigationwithLayoutContext@bottom-tabs/react-navigation's public API is unchanged - same exports, same types, same theme-derived tint defaults. It becomes a thin adapter over the shared view.Notable
colordependency for React Native'sprocessColor.coloris ESM-only, so every consumer who writes tests had to patchtransformIgnorePatternsbefore Jest would run at all.@react-navigation/nativestays at>=7. An earlier revision raised it to>=7.3.0, which brokenpm installoutright for SDK 52-55 apps locked below that - and nothing on that path needs 7.3.NativeBottomTabsContentcarries its event map and navigator props on phantom type-only properties. Without them an integrator loses every navigator prop at the call site:tabBarActiveTintColorand friends become type errors.unstable_createStandardRouterNavigatoris marked unstable by Expo and may change between minors. We deliberately don't call it ourselves, so a break stays in app code.tabBarreceives{ state, descriptors, actions, emitter }rather than anavigationobject, so@react-navigation/bottom-tabs'BottomTabBarcan't be used there. The React Navigation path is unaffected.How to test
apps/expo-router-testruns one assertion suite against both adapters under a real Expo Router tree, with a console spy that fails on any warning or error.Verified on an app scaffolded from
create-expo-app --template default@sdk-57(Expo 57, React Native 0.86.3, React 19.2.3):@react-navigation/*is absent fromnode_modulesentirely, so there's no second copy to line up - everything resolves through Expo Router's vendored fork.The SDK 52-55 path was checked separately: the documented
withLayoutContextrecipe typechecks clean against a realexpo-router@55install, at both 7.1.33 and 7.3.0.Screenshots