在构建自定义时Tab.Screen
,我尝试传递自定义tabBarIcon
。当图标呈现时,它不会导航到组件TestScreen
。在我理解的文档中,应该写成:tabBarIcon
Tab.Screen
<Tab.Screen
name={routes.FOO}
component={TestScreen}
options={{
tabBarIcon: ({ focused }) => (
<TouchableOpacity>
<View style={styles.actionButton}>
<Image source={plus} style={styles.imageIcon} />
</View>
</TouchableOpacity>
),
}}
/>
当我省略options
:
<Tab.Screen
name={routes.FOO}
component={TestScreen}
/>
单击时onClick
呈现组件。当我阅读有关屏幕选项的文档时,它提到screenOptions
应该在导航器或组上传递。我试着看看能不能找到类似的问答:
但我无法看到我的错误在哪里。
我当前的依赖项:
"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"
},
如何让我的自定义图标呈现并导航到正确的组件?