MCPcopy
hub / github.com/reduxjs/redux / bindActionCreators

Function bindActionCreators

src/bindActionCreators.ts:54–79  ·  view source on GitHub ↗
(
  actionCreators: ActionCreator<any> | ActionCreatorsMapObject,
  dispatch: Dispatch
)

Source from the content-addressed store, hash-verified

52>(actionCreators: M, dispatch: Dispatch): N
53
54export default function bindActionCreators(
55 actionCreators: ActionCreator<any> | ActionCreatorsMapObject,
56 dispatch: Dispatch
57) {
58 if (typeof actionCreators === 'function') {
59 return bindActionCreator(actionCreators, dispatch)
60 }
61
62 if (typeof actionCreators !== 'object' || actionCreators === null) {
63 throw new Error(
64 `bindActionCreators expected an object or a function, but instead received: '${kindOf(
65 actionCreators
66 )}'. ` +
67 `Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?`
68 )
69 }
70
71 const boundActionCreators: ActionCreatorsMapObject = {}
72 for (const key in actionCreators) {
73 const actionCreator = actionCreators[key]
74 if (typeof actionCreator === 'function') {
75 boundActionCreators[key] = bindActionCreator(actionCreator, dispatch)
76 }
77 }
78 return boundActionCreators
79}

Callers 5

boundFunction · 0.85
mapDispatchToPropsFunction · 0.85
mapDispatchToPropsFunction · 0.85
mapDispatchToPropsFunction · 0.85

Calls 2

kindOfFunction · 0.90
bindActionCreatorFunction · 0.85

Tested by

no test coverage detected