首页 > 解决方案 > 尽管 promise 已解决,为什么还要调用 catch 案例?

问题描述

有人可以帮助我理解为什么调用 .catch 案例,尽管先前的承诺已成功解决? https://gist.github.com/defrian/fd6dd7f072754e833b60c7bd6ed45159 我收到的密码正确时(为什么它包含“有效负载”:“登录错误”?)

    Array [
        Object {
          "type": "login_user",
        },
       Object {
         "payload": Object {
           "name": "signedUser",
         },
         "type": "login_user_success",
       },
       Object {
         "payload": "Cannot read property 'dispatch' of undefined",
         "type": "login_user_fail",
       },
      ]

当我使用错误的密码时,我收到了(如我所料)

Array [
        Object {
          "type": "login_user",
        },
       Object {
         "payload": "signIn error ",
         "type": "login_user_fail",
       },
      ]

标签: firebasereact-nativereduxjestjsredux-thunk

解决方案


我发现了错误。它是由 NavigationService 调用引起的。当我使用 redux-thunk 时,我不得不将其更改为dispatch(() => NavigationService.navigate('Home'));


推荐阅读