For simplicity i am writing all screen names.! My structure is:
ApplicantsListNav //createStackNavigator
applicantsList
applicantsDetail
newApplicant
ClientsListNav // createStackNavigator
clientsList
clientsDetail
newClient
mainTab //createMaterialBottomTabNavigator
applicantsListNav
clientsListNav
AuthStack //createStackNavigator
LandingStack //createDrawerNavigator
mainTab
editProfile
AppNavigator //createSwitchNavigator this one is default
Auth
Landing
My problem is i have added a logout button in sidebar and onPressing that i need to log out that means i want to navigate to Auth route in Switch navigator for that i am using
const navigateAction = NavigationActions.navigate({
routeName: "AuthStack",
index: 0,
key: null,
action: NavigationActions.navigate({ routeName: "Auth" })
});
this.props.navigation.dispatch(navigateAction);
But even after dispatching above action it does't navigate to Auth , After inspecting redux actions i observe that if is actually dispatching an action for the navigation to AuthScreen but as soon as it dispatches another action dispatches automatically and navigate to LandingStack. Why this is happening?
I am new to react navigation. Is the above structure good or i am doing it in wrong way?