0

I'm having trouble with preventing user from going back to splash screen. Previously when I was working with React Navigation 4 this is what I used

const resetAction = StackActions.reset({
  index: 0,
  actions: [NavigationActions.navigate({ routeName: "HomeScreen" })]
});
navigation.dispatch(resetAction);

But in React Navigation 5 the I've tried the code below with no success:

const resetAction = CommonActions.reset({
  index: 0,
  actions: [CommonActions.navigate({ name: screenName })]
});
navigation.dispatch(resetAction);

or this:

navigation.reset({
  index: 0,
  routes: [{ name: "HomeScreen" }]
});

I've also tried to set gestureEnabled to false in both Stack.Screen options props or in Stack.Navigator screenOptions props, but I can still swipe right to go back to splash screen.

Does anyone have any workaround for this? Thank you.

  • find the answer that will really help you. [prevent user to go back on splash screen](https://stackoverflow.com/a/66208340/5681567) – Pravin Ghorle Feb 15 '21 at 12:51

1 Answers1

0

There is a guide for authentication flows in the website, might be useful: here.

Diogo Brito
  • 147
  • 5