如何在React-Navigation中将通知计数组件添加到DrawerItem中?

时间:2018-11-14 06:50:36

标签: javascript reactjs react-native react-navigation react-navigation-drawer

我有一个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需要该组件。

enter image description here

0 个答案:

没有答案