我有一个开关导航器和底部标签导航器。Swich Navigator具有登录屏幕,底部选项卡Navigator具有主屏幕和注销屏幕。
切换导航器:
const RootStack = createSwitchNavigator(
{
AuthLoadingScreen: AuthLoadingScreen,
Auth: AuthStack,
AADB2CLogin: AADB2CLogin,
Home: mainBottomStack
},
{
initialRouteName: "AuthLoadingScreen",
transitionConfig
}
);
底部选项卡导航器:
const mainBottomStack = createBottomTabNavigator(
{
Home: mainStack,
MedicalRecord: MedicalRecordStack,
//MedicalRecord: PatientDetails,
Visit: VisitStack,
Alerts: AlertStack,
Profile: PatientDetails,
//Settings: Logout
Logout: {
screen: () => null,
navigationOptions: {
tabBarOnPress: () => {
Alert.alert(
"Logout",
"Are you sure you want to logout?",
[
{
text: "No",
style: "cancel"
},
{
text: "Yes",
onPress: () => {
console.log("logout");
//I want to navigate to switch navigator's Auth screen here...
}
}
],
{ cancelable: false }
);
}
}
}
},
{
transitionConfig,
initialRouteName: "Home",
barStyle: { backgroundColor: "#694fad" }
}
);
注销时,在底部选项卡导航器中,我想导航到切换导航器(到身份验证屏幕)。如何在react导航中在不同堆栈之间导航?