Skip to content

Commit 45a768e

Browse files
authored
Fixed TabBar scroll when there is selected index (#2630)
1 parent 25585c2 commit 45a768e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/components/tabController/TabBar.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,7 @@ const TabBar = (props: Props) => {
165165
const tabBar = useRef<typeof FadedScrollView>();
166166
const [key, setKey] = useState<orientations>(Constants.orientation);
167167
const context = useContext(TabBarContext);
168-
const {
169-
items: contextItems,
170-
currentPage,
171-
targetPage,
172-
initialIndex,
173-
containerWidth: contextContainerWidth
174-
} = context;
168+
const {items: contextItems, currentPage, targetPage, containerWidth: contextContainerWidth} = context;
175169
const containerWidth: number = useMemo(() => {
176170
return propsContainerWidth || contextContainerWidth;
177171
}, [propsContainerWidth, contextContainerWidth]);
@@ -194,7 +188,7 @@ const TabBar = (props: Props) => {
194188
// @ts-expect-error TODO: typing bug
195189
scrollViewRef: tabBar,
196190
itemsCount,
197-
selectedIndex: initialIndex,
191+
selectedIndex: currentPage.value,
198192
containerWidth,
199193
offsetType: centerSelected ? useScrollToItem.offsetType.CENTER : useScrollToItem.offsetType.DYNAMIC
200194
});

0 commit comments

Comments
 (0)