简体   繁体   English

如何在React Navigation中获取BottomTabNavigator来显示Modal StackNavigator?

[英]How do I get a BottomTabNavigator in React Navigation to display a Modal StackNavigator?

I have a bottom tab navigator with a handful of tabs. 我有一个带有少数标签的底部标签导航器。

When the user isn't logged under certain conditions I wanna navigate to a modal screen that is a stack navigator. 当用户在某些情况下未登录时,我想导航到作为堆栈导航器的模式屏幕。

How do I do this register the navigator with my bottom tab navigator without it being a tab? 如何在没有标签的情况下向底部标签导航器注册该导航器?

Solution

Wrap your main BottomTabNavigator and Login Screen(StackNavigator) using StackNavigator with Modal mode. 使用Modal模式的StackNavigator包裹您的主要BottomTabNavigator和登录屏幕(StackNavigator)。

For example 例如

import { createSwitchNavigator, createStackNavigator, createAppContainer } from 'react-navigation';

// Implementation of HomeScreen, OtherScreen, SignInScreen, AuthLoadingScreen
// goes here.

const AppStack = createStackNavigator({ Home: HomeScreen, Other: OtherScreen });
const AuthStack = createStackNavigator({ SignIn: SignInScreen });

export default createAppContainer(createStackNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    App: AppStack,
    Auth: AuthStack,
  },
  {
    initialRouteName: 'AuthLoading',
    mode: 'modal',
  }
));

Official will be helped. 官方会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 BottomTabNavigator react-navigation v5 内嵌套 StackNavigator - Nesting StackNavigator inside BottomTabNavigator react-navigation v5 在 React Navigation v3 中单击 React Native 中 bottomTabNavigator 上的选项卡时,如何刷新我的组件? - How do I refresh my component when clicked on tab on bottomTabNavigator in React Native, in React Navigation v3? 如何使用反应导航更新 stacknavigator 上的自定义标题? - How can I update a custom title on stacknavigator with react navigation? 如何在 React Modal 上显示组件 - How do I display a component on React Modal React Navigation-如何将抽屉导航器嵌套在stackNavigator中 - React navigation - how to nest drawerNavigator inside stackNavigator 如何在 React Navigation 5 中结合 StackNavigator 和 TabNavigator? - How to combine StackNavigator and TabNavigator in React Navigation 5? react-native:我如何在模态中的某处进行导航 - react-native: how can I do a navigation somewhere in a modal React Native BottomTabNavigator 导航不起作用 - React Native BottomTabNavigator navigation not working React Navigation bottomTabNavigator“createRouter 不是函数” - React Navigation bottomTabNavigator "createRouter is not a function" React Native Navigation(StackNavigator):我收到一条错误消息:“ undefined不是对象(正在评估'this.props.navigate')” - React Native Navigation(StackNavigator): I get an error saying “ undefined is not an object (evaluating 'this.props.navigate') ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM