1

My current structure is

const AppNavigator = createSwitchNavigator({
AuthLoading,
MainNavigator,
AuthNavigator
},
{
 initialRouteName: 'AuthLoading'
});

AuthNavigator

const OtpVerificationStack = createSwitchNavigator({
OTPLoading,
SignupNavigator,
MainNavigator
},
{
initialRouteName: 'OTPLoading',
});

const AuthNavigator = createStackNavigator({
VerificationNavigator,
OtpVerificationStack
},
{
initialRouteName: 'VerificationNavigator',
header: null,
headerMode: 'none'
 });

VerificationNavigator

const VerificationNavigator = createStackNavigator({
MobileNo,
OTPVer
},
{
header: null,
headerMode: 'none'
});

When I register user i.e. from AuthNavigator -> VerificationNavigator(after otpver screen to otpverificationStack) -> OTPVerificationStack -> SignupNavigator(screen 1) there is a google login option here, so when someone logs in using this I need to reset route to MainNavigator. I tried kee[ing key null, or MainNavigator while dispatching a resetAction but it returns undefined route error.

Divye Shah
  • 747
  • 1
  • 11
  • 24
  • did you check this: https://stackoverflow.com/questions/49826920/how-to-navigate-between-different-nested-stacks-in-react-navigation you can add a reset action to the answer in this post. You'd just pass the name of the other stack you are trying to navigate – kivul Feb 21 '19 at 17:56
  • @kivul I tried keeping key as OTPVerificationStack and routeName as MainNavigator. Keeping the key as a stacknavigator, I had to pass routeName as a navigator too. It seems that does not work. – Divye Shah Feb 21 '19 at 20:16
  • I am curious to know why you would like to have `VerificationNavigator` as a separate stack navigator? Instead you can make use of those screens in AuthNavigator itself. – 10101010 Feb 23 '19 at 11:16
  • Also why reset, when you can navigate to `MainNavigator `? – 10101010 Feb 23 '19 at 11:26
  • @10101010 I need to verify user with OTP. If the user exists I just get user data and go to MainNavigator else I continue with signup, hence. Also If I do that, when the user presses the back button in the phone it goes back to the old screen. – Divye Shah Feb 25 '19 at 07:48

0 Answers0