Skip to content

Commit

Permalink
fix: fix for dynamic tabs loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLindhout committed Aug 2, 2023
1 parent 7b85150 commit cc37d86
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/TabsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import * as React from 'react';
import { useIndicator, useOffsetScroller } from './internal';
import TabsHeaderItem from './TabsHeaderItem';
import { TabsContext } from './context';
import type { ReactElement } from 'react';
import type { TabScreenProps } from './TabScreen';

export default function TabsHeader({
children,
position,
offset,
theme,
Expand All @@ -24,7 +25,9 @@ export default function TabsHeader({
showLeadingSpace,
uppercase,
mode,
...rest
}: SwiperRenderProps) {
const children = React.Children.toArray(rest.children).filter(Boolean);
const { index, goTo } = React.useContext(TabsContext);
const { colors, dark: isDarkTheme, mode: themeMode, isV3 } = theme;
const {
Expand Down Expand Up @@ -194,11 +197,11 @@ export default function TabsHeader({
<View style={styles.scrollablePadding} />
) : null}

{React.Children.map(children.filter(Boolean), (tab, tabIndex) => (
{React.Children.map(children, (tab, tabIndex) => (
<TabsHeaderItem
theme={theme}
tabIndex={tabIndex}
tab={tab}
tab={tab as ReactElement<TabScreenProps>}
active={index === tabIndex}
onTabLayout={onTabLayout}
goTo={goTo}
Expand Down

0 comments on commit cc37d86

Please sign in to comment.