Reputation: 661
I am trying to navigate from one of the tabs in TabNavigator to a screen in the StackNavigator with a reset action. Here is (abbreviated) code:
...
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);
I'm trying to get from Friends
in FriendsNavigator
to Login
in Main
and reset the stack (as if the user was logging out). Does anyone have any ideas?
Upvotes: 1
Views: 2680
Reputation: 123
I'm very new to all this, but I think you need to have a master (my word) navigator. I make mine a stackNavigator, and then hide it when I don't want it - likewise with the tabNavigator.
Here is my code that works:
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
}
});
Upvotes: 2