我如何将外部/全局样式应用于React-Navigation底部选项卡
我试图将全局样式应用于React-Native的底部标签导航,但它无法在ScreenOptions Prop中接受。但是当我使用普通的内联样式时,它可以正常工作。请帮忙
export default function CustomBottomTab() {
return (
<Tab.Navigator
screenOptions={{
tabBarStyle: {styles.customTab} //underlines the dot as an error
}}
>
<Tab.Screen
name='Landing'
component={HomeScreen}
options={{
tabBarIcon: (props) => <AntDesign name='home' size={20} {...props} />,
}}
/>
<Tab.Screen
name='Notifications'
component={NotifScreen}
options={{
tabBarIcon: (props) => (
<FontAwesome5 name='bell' size={20} {...props} />
),
}}
/>
<Tab.Screen
name='Wishlist'
component={WishScreen}
options={{
tabBarIcon: (props) => (
<Ionicons name='bookmarks-outline' size={20} {...props} />
),
}}
/>
<Tab.Screen
name='Messages'
component={MessagesScreen}
options={{
tabBarIcon: (props) => (
<FontAwesome5 name='comment' size={20} {...props} />
),
}}
/>
</Tab.Navigator>
);
}
I tried to apply a global style to a bottom tab navigation in react-native but it can't accept it in the screenOptions prop. But it works fine when I use normal inline styling. Please help
export default function CustomBottomTab() {
return (
<Tab.Navigator
screenOptions={{
tabBarStyle: {styles.customTab} //underlines the dot as an error
}}
>
<Tab.Screen
name='Landing'
component={HomeScreen}
options={{
tabBarIcon: (props) => <AntDesign name='home' size={20} {...props} />,
}}
/>
<Tab.Screen
name='Notifications'
component={NotifScreen}
options={{
tabBarIcon: (props) => (
<FontAwesome5 name='bell' size={20} {...props} />
),
}}
/>
<Tab.Screen
name='Wishlist'
component={WishScreen}
options={{
tabBarIcon: (props) => (
<Ionicons name='bookmarks-outline' size={20} {...props} />
),
}}
/>
<Tab.Screen
name='Messages'
component={MessagesScreen}
options={{
tabBarIcon: (props) => (
<FontAwesome5 name='comment' size={20} {...props} />
),
}}
/>
</Tab.Navigator>
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从
{styles.customtab}
中删除{}
。这不是有效的JavaScript语法。它必须是:
Remove
{}
from around{styles.customTab}
. It's not valid JavaScript syntax.It needs to be: