source: node_modules/react-redux/src/connect/mapDispatchToProps.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import type { Action, Dispatch } from 'redux'
2import bindActionCreators from '../utils/bindActionCreators'
3import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
4import { createInvalidArgFactory } from './invalidArgFactory'
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}
Note: See TracBrowser for help on using the repository browser.