Why are Redux actions called actions if they don't actually act upon the data and instead just return a payload?
Is there any other use for an action other than to be dispatched, why don't actions dispatch when called?
Is this just a way to future proof an app for use with multiple stores?
This also creates a need for mapDispatchToProps which is usually completely boilerplate code to wrap actions with dispatch calls
It can often be summarized with this function that takes an object of actions and returns a mapDispatchToProps function
// mapActionsToDispatchProps.js
const mapActionsToDispatchProps = actions => {
return dispatch => (
actions.mapEntries(action => (
(...args) => dispatch(action(...args))
)
)
)
export default mapActionsToDispatchProps
Object.mapEntries example.
Edit
I see that last question about mapDispachToProps being mostly boilerplate can be avoided by passing an object of actions directly and connect will map them for me.