React: Uncaught (in Promise) Typeerror: Dispatch is not a Function

Asked

Viewed 224 times

1

Hello,

For some reason I make a call and I get the desired return, but it gives an error of Dispatch, I’ve tried several things and nothing works.

My action:

export const formulariosExternos = dispatch => {
  return axios({
    method: "GET",
    url: `${API_CONTEUDO_EXTERNO}/conteudo/formularios-externos`,
    headers: {
      "content-type": "application/json"
    }
  }).then(response => {
    console.log("resposta do get", response.data);
    dispatch({
      type: FORMULARIOS_EXTERNOS,
      payload: response.data
    });
  });
};

Reduce:

case FORMULARIOS_EXTERNOS:
      console.log("reducer", action.payload)
      return {
        ...state,
        formulariosExternos: action.payload
      };

And exported in the component thus:

export default connect(mapStateToProps, {
  submitLogin,
  closeModalAvisoBloqueado, formulariosExternos
})(withRouter(LoginForm));

I’m calling in a component thus:

{console.log(this.props.formulariosExternos())}
  • Tries with this.props.dispatch I think that might be it

  • @Mayconf.Castro at what point this?

  • Barter dispatch({
 type: FORMULARIOS_EXTERNOS,
 payload: response.data
 });

  • error the same way, I have other endpoints using this Dispatch, even don’t find this.props in the action

  • Ta using mapDispatchToProps? in connect, instead of using mapStateToProps, use null

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.