反应本机导航5是否从底部选项卡注销?

问题描述 投票:-1回答:1

在版本4中navigation.dispatch(StackActions.reset({索引:0,键:null,操作:[NavigationActions.navigate({routeName:'Login'}))],}),);

版本5

我不能使用StackActions.reset和NavigationActions我该怎么办?

reactjs react-native react-navigation react-native-navigation
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.