Created
June 29, 2022 07:15
-
-
Save manakuro/01eebe4e7e7c6844836ac31915c63b82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {forwardRef, useCallback} from 'react'; | |
import {TouchableOpacity, Animated, View} from 'react-native'; | |
type Props = { | |
onPress: (index: number) => void; | |
index: number; | |
ref: React.RefObject<any>; | |
children: React.ReactNode; | |
}; | |
export const TabBarItem = forwardRef<any, Props>((props, ref) => { | |
const handlePress = useCallback(() => { | |
props.onPress(props.index); | |
}, [props]); | |
return ( | |
<TouchableOpacity | |
style={{paddingHorizontal: 16, paddingTop: 16, alignItems: 'center'}} | |
onPress={handlePress}> | |
<View style={{paddingBottom: 4}} ref={ref}> | |
<Animated.Text style={{color: 'white', fontSize: 16}}> | |
{props.children} | |
</Animated.Text> | |
</View> | |
</TouchableOpacity> | |
); | |
}); | |
TabBarItem.displayName = 'TabBarItem'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment