bindActionCreators
Note
You almost certainly do not need this function anymore.
Instead, check out the object shorthand of mapDispatchToProps
.
bindActionCreators()
is a utility function which wraps actions in dispatch()
so they may be called directly.
See Redux dispatches for what an action creator or a dispatch are.
js
import * as IncrementActionCreators from "./IncrementActionCreators";
console.log(IncrementActionCreators);
// { increment: Function, decrement: Function }
const boundIncrementActionCreators = bindActionCreators(
IncrementActionCreators,
// One must assume we got dispatch from somewhere ¯\_(ツ)_/¯
dispatch
);
// This will just make an action, and not do anything
IncrementActionCreators.increment();
// This will make that same action, then dispatch it
boundIncrementActionCreators.increment();