|
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
|
| Rev | Line | |
|---|
| [a762898] | 1 | import type { Action, Dispatch } from 'redux'
|
|---|
| 2 | import bindActionCreators from '../utils/bindActionCreators'
|
|---|
| 3 | import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps'
|
|---|
| 4 | import { createInvalidArgFactory } from './invalidArgFactory'
|
|---|
| 5 | import type { MapDispatchToPropsParam } from './selectorFactory'
|
|---|
| 6 |
|
|---|
| 7 | export 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.