在版本4中navigation.dispatch(StackActions.reset({索引:0,键:null,操作:[NavigationActions.navigate({routeName:'Login'}))],}),);
版本5
我不能使用StackActions.reset和NavigationActions我该怎么办?
NativgtionActions已在V5中删除,并已引入CommonActions ...因此,这里有可能的方法尝试[]
import { CommonActions } from '@react-navigation/native'; navigation.dispatch( CommonActions.reset({ index: 1, routes: [ { name: 'Home' }, { name: 'Profile', params: { user: 'jane' }, }, ], }) );
确保您用登录路径替换重置块详细的参考资料在这里https://reactnavigation.org/docs/en/navigation-actions.html