【问题标题】:React Navigation is not working in an axios call in react nativeReact Navigation 在 react native 的 axios 调用中不起作用
【发布时间】:2019-06-17 13:23:54
【问题描述】:

我正在尝试将用户导航到主屏幕,但我的导航不起作用。它显示登录成功但未导航到主屏幕的警报是我的代码...

 axios.post('/api_workreap/wp-json/api/v1/user/do_login', {
        username: username,
        password: password
          })
          .then((response) => {
            console.log(JSON.stringify(response.data.type));
            if(response.data.type == "success"){
              alert("Login Successfully");
              // this.props.navigation.navigate("/src/Home/home.js");
              NavigationActions.navigate({ routeName: 'home' })
            }else if(response.data.type == "error"){
              alert("Incorrect Detail");
            }
        })
          .catch((error) => {
            console.log( JSON.stringify(response));
          });

【问题讨论】:

  • 你用的是什么导航?
  • 反应导航

标签: reactjs react-native axios react-navigation


【解决方案1】:

你可以试试this,基本上在你的导航路由器上创建你自己的导航服务,教程很简单。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-03
    • 2020-08-26
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    相关资源
    最近更新 更多