expo-router-v3-top-tabs
v0.1.0
Published
Top tabs with optional header in Expo Router based on @bacons/expo-router-top-tabs
Downloads
23
Maintainers
Readme
@bacons/expo-router-top-tabs
I made some major fixes. I got this error message via Expo development server:
"Unable to resolve "expo-router/src/layouts/withLayoutContext" from "node_modules/@bacons/expo-router-top-tabs/build/index.js"
I figured out that Expo Router V3 doesn not have a
expo-router/src/
folder but ratherexpo-router/build
. So, I made corrections to theexpo-router/src/layouts/withLayoutContext
file.
Wraps react-native-collapsible-tab-view
and adds support for Expo Router.
Add the package to your npm dependencies
yarn add @bacons/expo-router-top-tabs react-native-reanimated
- Setup Reanimated in the
babel.config.js
. See here for more info.
Usage
Example in Layout Route:
// app/(tabs)/_layout.tsx
import { Text, View } from "react-native";
import { TopTabs } from "@bacons/expo-router-top-tabs";
export default function CustomLayout() {
return (
<TopTabs screenOptions={{}}>
<TopTabs.Header>
<View pointerEvents="none" style={{}}>
<Text>Header</Text>
</View>
</TopTabs.Header>
<TopTabs.Screen name="index" />
</TopTabs>
);
}
Usage in child routes:
// app/(tabs)/index.tsx
import { Animated } from "react-native";
import { useScrollProps } from "@bacons/expo-router-top-tabs";
export default function Screen() {
const props = useScrollProps();
return <Animated.ScrollView {...props}></Animated.ScrollView>;
}