React Navigation - 从TabNavigator导航到StackNavigator

时间:2017-04-12 19:59:02

标签: reactjs react-native react-navigation

我正尝试使用重置操作从TabNavigator中的一个选项卡导航到StackNavigator中的屏幕。这是(缩写)代码:

...

const FriendsNavigator = StackNavigator({
 Friends: { screen: Friends },
})

const TabsNavigator = TabNavigator({
 Home: { screen: HomeNavigator },
 Schedule: { screen: ScheduleNavigator },
 Friends: { screen: FriendsNavigator },
 Activity: { screen: ActivityNavigator }
})

const Main = StackNavigator({
 Login: { screen: Login },
 Tabs: { screen: TabsNavigator }
})

AppRegistry.registerComponent('Main', () => Main);

我正试图从Friends中的FriendsNavigatorLogin中的Main并重置堆栈(就像用户注销一样)。有没有人有任何想法?

1 个答案:

答案 0 :(得分:2)

我对这一切都很陌生,但我认为你需要一个主人(我的话)导航器。我把它作为stackNavigator,然后在我不想要的时候隐藏它 - 同样使用tabNavigator。

这是我的代码:

 const MainNavigator = StackNavigator({
      loginForm: { screen: LoginForm },
      main: {
        screen: TabNavigator({
          groupMain: { screen: GroupMain },
          feedback: { screen: Feedback },
          settings: { screen: Settings },
          groupScreen: {
            screen: TabNavigator({
            groupScreens:  { screen: GroupPage},
            feedbackInput: { screen: FeedbackInput}
            })
          }
        })
      }
    }, {
      navigationOptions: {
        tabBarVisible: false,
        header: null
      }
    });