我想在注销用户时重置堆栈导航堆栈。当前,如果我注销,我的用户将被带到使用switchNavigator的身份验证屏幕,如果用户重新登录,他们将被带到他们注销时最后一次进入的屏幕。我希望用户在注销并再次登录后被定向到客户提要。
我的导航器看起来像这样
export const Tabs = DrawerNavigator(
{
AuthLoading: AuthLoading,
Auth: UnAuthenticatedTabs,
App: AuthenticatedTabs
},
{
contentComponent: SideMenu,
initialRouteName: 'AuthLoading',
}
);
const UnAuthenticatedTabs = SwitchNavigator({
LogIn: { screen: SignIn },
Registration: { screen: Registration },
ForgotPassword: { screen: ForgotPassword }
})
const AuthenticatedTabs = StackNavigator({
CustomerFeed: { screen: CustomerFeed,
navigationOptions: ({ navigation }) => ({
title: 'Customer Feed',
})
},
Customer: { screen: Customer,
navigationOptions: ({ navigation }) => ({
title: 'Customer'
})
},
})
答案 0 :(得分:0)
最终对我有用的是当用户登录并路由到stackNavigator时重置堆栈。用户注销并路由到switchNavigator时尝试重置stackNavigator时不行。
const resetAction = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: 'CustomerFeed' })],
});
this.props.navigation.dispatch(resetAction);