When building a custom Tab.Screen
I've tried to pass a custom tabBarIcon
. While the icon renders it will not navigate to the component TestScreen
. In the docs for tabBarIcon
my understanding the Tab.Screen
should be written as:
<Tab.Screen
name={routes.FOO}
component={TestScreen}
options={{
tabBarIcon: ({ focused }) => (
<TouchableOpacity>
<View style={styles.actionButton}>
<Image source={plus} style={styles.imageIcon} />
</View>
</TouchableOpacity>
),
}}
/>
When I omit the options
:
<Tab.Screen
name={routes.FOO}
component={TestScreen}
/>
the onClick
renders the component when clicked. When I read the docs for Options for screens it mentions screenOptions
should be passed on the Navigator or Group. I tried to see if I could find a similar Q&A:
- React native react-navigation tabBarIcon does not display
- Why Is My Component not Rendering Within my Tab.Screen?
but I was unable to see where my error is.
My current dependencies:
"dependencies": {
"@react-navigation/bottom-tabs": "^6.0.5",
"@react-navigation/native": "^6.0.2",
"expo": "~42.0.1",
"expo-status-bar": "~1.0.4",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
"react-native-gesture-handler": "^1.10.3",
"react-native-safe-area-context": "3.2.0",
"react-native-screens": "~3.4.0",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"@babel/core": "^7.9.0"
},
How can I get my custom icon to render and navigate to the correct component?