React Native中的嵌套导航

时间:2019-06-28 08:40:02

标签: reactjs react-native react-native-android mobile-application

这是我的代码。我想创建类似Swiper-> Auth-> Passcode-> App的导航。如您在这里看到的,我想要AuthStack内的PassCode Switch Navigator,但是我得到的错误是这里Erro Image Links

array (
  'hierarchical' => true,
  'posts_per_page' => '-1',
  'post_type' => 'post',
  'tax_query' => 
  array (
    'taxonomy' => 'post_format',
    'field' => 'slug',
    'terms' => 
    array (
      0 => 'post-format-gallery', //I WANT TO REMOVE THIS KEY
    ),
  ),
  'category_name' => NULL,
)

我是React-native的新手。除了文档之外,我还需要一个更好的关于本机嵌套导航的文档。

1 个答案:

答案 0 :(得分:1)

您需要重新排列堆栈或路由的创建顺序。

错误是PassCodeStack不能在初始化之前使用,因为它未定义,因此它必须是组件。

const PassCodeStack = createSwitchNavigator(
  {
    PassCodeLoading: PassCodeLoadingScreen,
    PassCode: PassCodeScreen,
  },
  {
    initialRouteName:'PassCodeLoading'
  }
);

const AuthStack = createStackNavigator({ 
    SignIn: SignInScreen,
    OTP:OTPScreen,
    PassCodeNavigation : PassCodeStack 
// I want to put Switch Naviagtor here.
// Error is : "The Component for route 'PassCodeNavigation' must be a 
// React Component.

  },
    {
      initialRouteName:'SignIn'
    }
  );


const MyAppNavigation = createSwitchNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    App: AppStack,
    Auth: AuthStack,
    Swiper:SwiperScreen
  },
  {
    initialRouteName: 'AuthLoading',
  }
)