MCPcopy Create free account
hub / github.com/Mindinventory/react-native-tabbar-interaction / App

Function App

example/src/App.tsx:11–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9const { width: screenWidth } = Dimensions.get('window');
10
11export default function App() {
12 const tabs = useMemo(() => tabData, []);
13 const flatListRef = useRef<FlatList>(null);
14
15 const onTabChange = useCallback((_item: TabsType, index: number) => {
16 flatListRef.current?.scrollToIndex({
17 animated: true,
18 index: index,
19 });
20 }, []);
21
22 return (
23 <View style={styles.container}>
24 <FlatList
25 ref={flatListRef}
26 data={tabs}
27 keyExtractor={(item) => item.name}
28 renderItem={({ item }: { item: TabsDataType }) => {
29 return (
30 <View
31 style={[
32 styles.slide,
33 {
34 backgroundColor: item.activeTintColor,
35 },
36 ]}
37 >
38 <Text style={styles.titleText}>{item.name}</Text>
39 </View>
40 );
41 }}
42 scrollEnabled={false}
43 horizontal
44 bounces={false}
45 pagingEnabled
46 showsHorizontalScrollIndicator={false}
47 />
48 <TabBar
49 tabs={tabs as Array<TabsType>}
50 onTabChange={onTabChange}
51 containerWidth={screenWidth - 30}
52 containerBottomSpace={30}
53 />
54 </View>
55 );
56}
57
58const styles = StyleSheet.create({
59 container: { flex: 1 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected