我有一个Drawer Navigator(它使用v2,并且实际上与v3.rc5几乎相同)
export const AuthMenu = createDrawerNavigator(
{
Home: {
screen: MainStack,
path: 'home',
navigationOptions: {
drawerLabel: () => null
}
},
Notifications: {
screen: Screen.Notifications,
path: 'notifications',
navigationOptions: {
drawerLabel: 'Notifications'
}
},
},
{
stateName: 'AuthMenu',
initialRouteName: 'Home',
contentComponent: (props) => {
return <AuthDrawer {...props} />;
},
defaultNavigationOptions: ({ navigation }) => ({
headerLeft: (
<MaterialCommunityIcons
name="menu"
onPress={() => {
navigation.openDrawer();
Keyboard.dismiss();
}}
/>
)
})
}
);
我想在菜单中添加一个通知计数组件,所以我可以看到下图所示的内容-这似乎是一个常见的用例。如何才能做到这一点?仅Notifications DrawerItem需要该组件。