Skip to content

Instantly share code, notes, and snippets.

@manakuro
Created June 29, 2022 07:15
Show Gist options
  • Save manakuro/4e3f7a922ebb37da47e0f9a07813fbf5 to your computer and use it in GitHub Desktop.
Save manakuro/4e3f7a922ebb37da47e0f9a07813fbf5 to your computer and use it in GitHub Desktop.
import React from 'react';
import {TabViewProps, Route} from 'react-native-tab-view';
import {View} from 'react-native';
import {TabBarItem} from './TabBarItem';
type Props<T extends Route> = Parameters<
NonNullable<TabViewProps<T>['renderTabBar']>
>[0] & {
onIndexChange: (index: number) => void;
};
export const TabBar = <T extends Route>(props: Props<T>) => {
return (
<View
style={{
flexDirection: 'row',
borderBottomWidth: 0.5,
borderStyle: 'solid',
borderBottomColor: 'rgba(255, 255, 255, 0.24)',
}}>
{props.navigationState.routes.map((route, i) => (
<TabBarItem key={i} onPress={props.onIndexChange} index={i}>
{route.title}
</TabBarItem>
))}
</View>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment