MCPcopy
hub / github.com/reduxjs/react-redux / mapDispatchToPropsFactory

Function mapDispatchToPropsFactory

src/connect/mapDispatchToProps.ts:7–25  ·  view source on GitHub ↗
(
  mapDispatchToProps:
    | MapDispatchToPropsParam<TDispatchProps, TOwnProps>
    | undefined,
)

Source from the content-addressed store, hash-verified

5import type { MapDispatchToPropsParam } from './selectorFactory'
6
7export function mapDispatchToPropsFactory<TDispatchProps, TOwnProps>(
8 mapDispatchToProps:
9 | MapDispatchToPropsParam<TDispatchProps, TOwnProps>
10 | undefined,
11) {
12 return mapDispatchToProps && typeof mapDispatchToProps === 'object'
13 ? wrapMapToPropsConstant((dispatch: Dispatch<Action<string>>) =>
14 // @ts-ignore
15 bindActionCreators(mapDispatchToProps, dispatch),
16 )
17 : !mapDispatchToProps
18 ? wrapMapToPropsConstant((dispatch: Dispatch<Action<string>>) => ({
19 dispatch,
20 }))
21 : typeof mapDispatchToProps === 'function'
22 ? // @ts-ignore
23 wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps')
24 : createInvalidArgFactory(mapDispatchToProps, 'mapDispatchToProps')
25}

Callers 1

connect.tsxFile · 0.90

Calls 4

wrapMapToPropsConstantFunction · 0.90
wrapMapToPropsFuncFunction · 0.90
createInvalidArgFactoryFunction · 0.90
bindActionCreatorsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…