Redux-thunk - dispatch is not a function

1

Hello, I'm having problems with redux-thunk . The console shows me the error saying that dispatch is not defined within my action, I tried to give console.log of the arguments I get in the function and I'm not getting anything.

The error happens to the 5th line of the action. In the 3rd I added a console.log that returns undefined .

Code:

Action

export function signUp(data) {
  return dispatch => {
    console.log(dispatch)
    if (data.email === '[email protected]') {
      dispatch(signIn(data, () => {
        if (data.type === '2') {
          browserHistory.push('/settings/profile')
        } else {
          browserHistory.push('/')
        }
      }))
    } else {
      return {
        type: ActionTypes.USER_SIGN_UP__ERROR
      }
    }
  }
}'

mapActionsToProps

const mapActionsToProps = dispatch => ({
  signUp (data) {
    console.log(dispatch)
    dispatch(userActions.signUp(data))
  }
})

As you can see, I have printed the dispatch function inside mapActionsToProps on the console and is returning as expected:

  function (action) {
    if (typeof action === 'function') {
      return action(dispatch, getState, extraArgument);
    }

    return next(action);
  }

Thank you

    
asked by anonymous 23.01.2017 / 13:42

0 answers