Skip to content

Commit cc37d86

Browse files
fix: fix for dynamic tabs loop
1 parent 7b85150 commit cc37d86

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/TabsHeader.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import * as React from 'react';
1111
import { useIndicator, useOffsetScroller } from './internal';
1212
import TabsHeaderItem from './TabsHeaderItem';
1313
import { TabsContext } from './context';
14+
import type { ReactElement } from 'react';
15+
import type { TabScreenProps } from './TabScreen';
1416

1517
export default function TabsHeader({
16-
children,
1718
position,
1819
offset,
1920
theme,
@@ -24,7 +25,9 @@ export default function TabsHeader({
2425
showLeadingSpace,
2526
uppercase,
2627
mode,
28+
...rest
2729
}: SwiperRenderProps) {
30+
const children = React.Children.toArray(rest.children).filter(Boolean);
2831
const { index, goTo } = React.useContext(TabsContext);
2932
const { colors, dark: isDarkTheme, mode: themeMode, isV3 } = theme;
3033
const {
@@ -194,11 +197,11 @@ export default function TabsHeader({
194197
<View style={styles.scrollablePadding} />
195198
) : null}
196199

197-
{React.Children.map(children.filter(Boolean), (tab, tabIndex) => (
200+
{React.Children.map(children, (tab, tabIndex) => (
198201
<TabsHeaderItem
199202
theme={theme}
200203
tabIndex={tabIndex}
201-
tab={tab}
204+
tab={tab as ReactElement<TabScreenProps>}
202205
active={index === tabIndex}
203206
onTabLayout={onTabLayout}
204207
goTo={goTo}

0 commit comments

Comments
 (0)