Search code examples
reactjsreduxreact-reduxredux-saga

redux-saga TypeError: Cannot read property 'email' of undefined


I'm sure there's a very simple reason why my code isn't working but I have been trying to understand why for a couple days and haven't been making progress.

I'm trying to sign the user in directly after they sign up. Any recommendations on the code itself would be appreciated as well.

[Actions][1]
[Types][2]
[User Sagas 1][3]
[User Sagas 2][4]
[User Reducer][5]
[Error][6]

1: https://i.sstatic.net/hOb0i.png

2: https://i.sstatic.net/3heqj.png

3: https://i.sstatic.net/pmWiF.png

4: https://i.sstatic.net/9FTnA.png

5: https://i.sstatic.net/uoGo3.png

6: https://i.sstatic.net/GSSsw.png


Solution

  • in the SignInStart and SignUpSuccess you need to pass email and password as an object. like so:

    export const SignInStart = (email, password) => ({
      type: UserActionTypes.SIGN_IN_START,
      payload: { email, password }
    });
    

    because your saga function (signIn), expect to get a payload object in this shape:

     const payload = {
         email: 'example'
        password: 'password'
    }