【问题标题】:react navigation the reset action not working反应导航重置操作不起作用
【发布时间】:2018-07-16 09:47:16
【问题描述】:

index.js 有类似这样的带有 StackNavigator 的代码

const App = StackNavigator({
  Home: {
    screen: Home,
  },
});

const AppNavigator = StackNavigator(
  {
    Login: {
      screen: SignIn,
    },
    SignUp: {
      screen: SignUp,
    },
    myApp: { screen: App },
  },
  {
    gestureEnabled: false,
    headerMode: 'none',
  },

);

我正在登录并推送到 myApp 路由,

this.props.navigation.dispatch(
      NavigationActions.reset({
        index: 0,
        key: null,
        actions: [NavigationActions.navigate({ routeName: 'myApp' })]
      })
    );

所有导航推送和弹出返回工作现在我正在尝试切除那不起作用。

从家里我想去登录屏幕。我正在注销操作

logoutPressed() {

    const resetAction = NavigationActions.reset({
              index: 0,
              actions: [NavigationActions.navigate ({ routeName:  
              'Login' })],
     });

     this.props.navigation.dispatch(resetAction);

}

错误:routeName: 'Login' not found in StackNavigator 什么问题。如何解决。

【问题讨论】:

    标签: ios reactjs react-native react-navigation react-native-ios


    【解决方案1】:

    你必须按如下方式编写堆栈导航器

     const App = StackNavigator({
          Home: {
            screen: Home,
          },
          Login: {
            screen: SignIn,
          },
      });
    

    App StackNavigator 没有登录路径,您需要在其导航中包含路径名称

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-11
      • 2019-10-21
      • 2020-07-20
      • 1970-01-01
      • 1970-01-01
      • 2020-01-13
      • 2021-04-20
      • 1970-01-01
      相关资源
      最近更新 更多