Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fresh-pugs-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@bottom-tabs/expo-template': patch
---

fix: provide proper typings for withLayoutContext
26 changes: 19 additions & 7 deletions docs/docs/docs/guides/usage-with-expo-router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,29 @@ First install `@bottom-tabs/react-navigation` which provides a native bottom tab

<PackageManagerTabs command="install @bottom-tabs/react-navigation" />

First, create a custom layout adapter for the native bottom tabs:
Next, create a custom layout adapter for the native bottom tabs using `withLayoutContext` from Expo Router:

```tsx
import { withLayoutContext } from "expo-router";
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';

export const Tabs = withLayoutContext(
createNativeBottomTabNavigator().Navigator
);
import { withLayoutContext } from 'expo-router';
import {
createNativeBottomTabNavigator,
NativeBottomTabNavigationOptions,
NativeBottomTabNavigationEventMap,
} from '@bottom-tabs/react-navigation';
import { ParamListBase, TabNavigationState } from '@react-navigation/native';

const BottomTabNavigator = createNativeBottomTabNavigator().Navigator;

const Tabs = withLayoutContext<
NativeBottomTabNavigationOptions,
typeof BottomTabNavigator,
TabNavigationState<ParamListBase>,
NativeBottomTabNavigationEventMap
>(BottomTabNavigator);
```

> [!NOTE] Make sure to provide the correct types for the `withLayoutContext` function. Without it screen options won't have proper types.

Then, use the `Tabs` navigator in your app:

```tsx
Expand Down
16 changes: 14 additions & 2 deletions packages/expo-template/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import React from 'react';
import { withLayoutContext } from 'expo-router';
import { createNativeBottomTabNavigator } from '@bottom-tabs/react-navigation';
import {
createNativeBottomTabNavigator,
NativeBottomTabNavigationOptions,
NativeBottomTabNavigationEventMap,
} from '@bottom-tabs/react-navigation';
import { ParamListBase, TabNavigationState } from '@react-navigation/native';

const Tabs = withLayoutContext(createNativeBottomTabNavigator().Navigator);
const BottomTabNavigator = createNativeBottomTabNavigator().Navigator;

const Tabs = withLayoutContext<
NativeBottomTabNavigationOptions,
typeof BottomTabNavigator,
TabNavigationState<ParamListBase>,
NativeBottomTabNavigationEventMap
>(BottomTabNavigator);

export default function TabLayout() {
return (
Expand Down
Loading