Search code examples
firebasereact-nativereduxjestjsredux-thunk

Why is the catch case called although the promise is resolved?


can someone help me understand why the .catch case is called although the prior promise is resolved successfully? https://gist.github.com/defrian/fd6dd7f072754e833b60c7bd6ed45159 when the password is correct i recieve (why does it contain the “payload”: “signIn error”?)

    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",
       },
      ]

when I use a wrong password I recieve (as I expect)

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

Solution

  • I found the error. It was caused by the NavigationService call. As I am using redux-thunk I had to change it to dispatch(() => NavigationService.navigate('Home'));