amis-rpc-design/node_modules/react-redux/es/connect/mapDispatchToProps.js

10 lines
714 B
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
import bindActionCreators from '../utils/bindActionCreators';
import { wrapMapToPropsConstant, wrapMapToPropsFunc } from './wrapMapToProps';
import { createInvalidArgFactory } from './invalidArgFactory';
export function mapDispatchToPropsFactory(mapDispatchToProps) {
return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? wrapMapToPropsConstant(dispatch => // @ts-ignore
bindActionCreators(mapDispatchToProps, dispatch)) : !mapDispatchToProps ? wrapMapToPropsConstant(dispatch => ({
dispatch
})) : typeof mapDispatchToProps === 'function' ? // @ts-ignore
wrapMapToPropsFunc(mapDispatchToProps, 'mapDispatchToProps') : createInvalidArgFactory(mapDispatchToProps, 'mapDispatchToProps');
}