Skip to content

Commit 8091f29

Browse files
committed
Add 'initialTabIndex' prop to TabView
1 parent a6107eb commit 8091f29

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/core/src/components/TabView/TabView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type KeyboardDismissMode = "none" | "auto" | "on-drag";
2626
type TabViewProps = {
2727
onIndexChanged?: (index: number) => void;
2828
onEndReached?: () => void;
29+
initialTabIndex?: number;
2930
tabBarPosition?: TabBarPosition;
3031
keyboardDismissMode?: KeyboardDismissMode;
3132
swipeEnabled?: boolean;
@@ -43,6 +44,7 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
4344
Icon,
4445
onIndexChanged,
4546
onEndReached,
47+
initialTabIndex = 0,
4648
tabBarPosition,
4749
keyboardDismissMode,
4850
swipeEnabled,
@@ -56,7 +58,7 @@ const TabViewComponent: React.FC<React.PropsWithChildren<TabViewProps>> = ({
5658
theme,
5759
children: childrenProp,
5860
}) => {
59-
const [index, setIndex] = React.useState(0);
61+
const [index, setIndex] = React.useState(initialTabIndex);
6062
const [routes, setRoutes] = React.useState<Route[]>([]);
6163
const [tabScenes, setTabScenes] = React.useState<{ [key: string]: any }>({});
6264

0 commit comments

Comments
 (0)