react-navigation:嵌套路由不起作用

时间:2022-07-29 19:40:58

I am trying to achieve nested routing in the below example. But I am not able to navigate to "Other" route when I click on "Show me more of the app" button. Any help is appreciated.

我试图在下面的例子中实现嵌套路由。但是当我点击“显示更多应用程序”按钮时,我无法导航到“其他”路线。任何帮助表示赞赏。

https://snack.expo.io/rJYl02b6M

https://snack.expo.io/rJYl02b6M

I know I can add Other to the parent StackNavigator but I need some common component and that is why I want to wrap the OtherSr=tack router with a component.

我知道我可以将其他东西添加到父StackNavigator但我需要一些通用组件,这就是为什么我想用一个组件包装OtherSr = tack路由器。

1 个解决方案

#1


0  

Thanks for the live example. You just need to add:

谢谢你的实例。你只需要添加:

Other: OtherStack,

to your SwitchNavigator.

到您的SwitchNavigator。

So you'd have:

所以你有:

export default SwitchNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    App: AppStack, 
    Auth: AuthStack,
    Other: OtherStack,
  },
  {
    initialRouteName: 'AuthLoading',
  }
);

#1


0  

Thanks for the live example. You just need to add:

谢谢你的实例。你只需要添加:

Other: OtherStack,

to your SwitchNavigator.

到您的SwitchNavigator。

So you'd have:

所以你有:

export default SwitchNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    App: AppStack, 
    Auth: AuthStack,
    Other: OtherStack,
  },
  {
    initialRouteName: 'AuthLoading',
  }
);