Reputation: 209
Is there a way to access a root stack navigator from an inner stack navigator? For example:
const Root = StackNavigator(
{
Login: {
screen: Login,
},
TabNav: {
screen: TabNav
}
}
);
const TabNav = TabNavigator(
{
Content: {
screen: Content,
},
Settings: {
screen: SettingsStack
}
}
);
Within that SettingsStack screen I have a logout button. How would I access the Root Stack to navigate back to Login? Rather than that inner stack in the Tab Navigation just pushing to the login page within the child stack.
Upvotes: 0
Views: 450
Reputation: 722
From TabNav
in StackNavigator pass a function as a screenProp to TabNavigator
. Use the function whenever you want to logout. Since SettingsStack
is a navigator inside another navigator pass the props into SettingsStack
to make it work.
Upvotes: 3