nikasv nikasv -4 years ago 215
React JSX Question

How to Disable back swipe option or pop a route in React Navigation?

I have a Login Page(StackNavigator) and a Tabbed pages(TabNavigator).

export const Root = StackNavigator({
LoginScreen: {screen: Login},
Tabs: {screen: Tabs}
},
{
initialRouteName: 'LoginScreen'
}
)


After logging the user in there is still a possibility for the user to go back(to Login Page) by swiping back. What is the way of popping the login route from the Route Stack or disabling the back swipe option. Thanks

Answer Source

Dispatch a reset action instead of the normal navigation dispatch. That way you can set the stack to the state you want it to be after logging in and remove your LoginScreen from the stack.

Example related answers:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download