bindActionCreators.js 361 B

12345678910111213
  1. export default function bindActionCreators(actionCreators, dispatch) {
  2. const boundActionCreators = {};
  3. for (const key in actionCreators) {
  4. const actionCreator = actionCreators[key];
  5. if (typeof actionCreator === 'function') {
  6. boundActionCreators[key] = (...args) => dispatch(actionCreator(...args));
  7. }
  8. }
  9. return boundActionCreators;
  10. }