In a container, I've been using the "object shorthand" form of mapDispatchToProps
to make available a single redux action (initialized as createRoutine
from redux-actions
) in an event handler:
const mapDispatchToProps = {
validateAddress,
}
In the handler, the action appears in this form:
function () { return dispatch(actionCreator.apply(this, arguments));}
All good. But when instead I define mapDispatchToProps
as a function, so that I can add other actions that need access to dispatch
, like so...
const mapDispatchToProps = (dispatch) => {
return {
validateAddress: () => dispatch(validateAddress()),
newAction1: .......,
newAction2: .......,
}
}
...my original action, validateAddress
, ceases to work and appears now in this form instead:
function validateAddress() {
return dispatch(Object(_core_address_module__WEBPACK_IMPORTED_MODULE_9__["validateAddress"])());
}
I'm not sure why this is happening or how to restore the functionality of my original action. Any ideas? Thanks.
Your action creators such as
validateAddress
should return an object or a function that receives dispatch and getState functions for thunk actions.Here is a working example: