如何从 createBottomTabNavigator 中隐藏特定选项卡

How to hide specific tabs from createBottomTabNavigator

我需要从选项卡导航器中隐藏登录选项卡,但我不确定如何操作。我尝试使用 createStackNavigator 加载登录屏幕,然后使用底部选项卡导航器将一次登录传递到主屏幕,但我在所有屏幕上都留下了一个 return 箭头,这是我不想要的。

  Login: {
    screen: LoginScreen,
    navigationOptions: { tabBarVisible: false },
    tabBarOptions: { showLabel: false, showIcon: false },
  },
  Home: {
    screen: HomeScreen,
    navigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <Icon name="ios-home" size={28} color={tintColor} />
      ),
      header: null,
    },
  },
  Calories: {
    screen: CalorieScreen,
    navigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <MaterialIcon name="food" size={38} color={tintColor} />
      ),
      header: null,
    },
  },
  Booking: {
    screen: BookingScreen,
    navigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <FontIcon name="dumbbell" size={24} color={tintColor} />
      ),
      header: null,
    },
  },
  Weight: {
    screen: WeightScreen,
    navigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <FontIcon name="weight" size={26} color={tintColor} />
      ),
      header: null,
    },
  },
  Calendar: {
    screen: CalendarScreen,
    navigationOptions: {
      tabBarIcon: ({ tintColor }) => (
        <MaterialIcon name="calendar-month" size={28} color={tintColor} />
      ),
      header: null,
    },
  },
})

您应该使用 createSwitchNavigator 来阻止用户在成功登录后返回登录屏幕。 这里有一个来自 react-navigation 文档的实现示例:

https://reactnavigation.org/docs/en/auth-flow.html