不要在特定页面上显示侧边栏

时间:2019-02-14 20:07:58

标签: react-native react-navigation

我如何: 不在特定页面上打开抽屉导航器吗?

  Connexion: {
    screen: Connexion,
    navigationOptions: {
      drawerLabel: () => null,
    }
  },

I can open my sidebar here

1 个答案:

答案 0 :(得分:4)

我在react-navigation v2上有一个类似的问题。根据{{​​3}},您可以在路由初始化后立即定义导航选项,并禁止其在已定义的路由中显示Drawer导航器。

路线看起来像:

const RoutesStack = StackNavigator({
  Authentication: {
    screen: Authentication,
  },

然后我在其下添加了选项:

RoutesStack.navigationOptions = ({ navigation }) => {
 name = (navigation.state.index !== undefined ? navigation.state.routes[navigation.state.index] : navigation.state.routeName)
  let drawerLockMode = 'locked-closed'
  if (name.routeName != 'Authentication' && name.routeName != 'Signup') {
    drawerLockMode = 'unlocked'
  }

  return {
    drawerLockMode,
  };
}