You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					32 lines
				
				1.2 KiB
			
		
		
			
		
	
	
					32 lines
				
				1.2 KiB
			| 
											3 years ago
										 | import _extends from "@babel/runtime/helpers/esm/extends"; | ||
|  | import verifyPlainObject from '../utils/verifyPlainObject'; | ||
|  | import { createInvalidArgFactory } from './invalidArgFactory'; | ||
|  | export function defaultMergeProps(stateProps, dispatchProps, ownProps) { | ||
|  |   // @ts-ignore
 | ||
|  |   return _extends({}, ownProps, stateProps, dispatchProps); | ||
|  | } | ||
|  | export function wrapMergePropsFunc(mergeProps) { | ||
|  |   return function initMergePropsProxy(dispatch, { | ||
|  |     displayName, | ||
|  |     areMergedPropsEqual | ||
|  |   }) { | ||
|  |     let hasRunOnce = false; | ||
|  |     let mergedProps; | ||
|  |     return function mergePropsProxy(stateProps, dispatchProps, ownProps) { | ||
|  |       const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps); | ||
|  | 
 | ||
|  |       if (hasRunOnce) { | ||
|  |         if (!areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps; | ||
|  |       } else { | ||
|  |         hasRunOnce = true; | ||
|  |         mergedProps = nextMergedProps; | ||
|  |         if (process.env.NODE_ENV !== 'production') verifyPlainObject(mergedProps, displayName, 'mergeProps'); | ||
|  |       } | ||
|  | 
 | ||
|  |       return mergedProps; | ||
|  |     }; | ||
|  |   }; | ||
|  | } | ||
|  | export function mergePropsFactory(mergeProps) { | ||
|  |   return !mergeProps ? () => defaultMergeProps : typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : createInvalidArgFactory(mergeProps, 'mergeProps'); | ||
|  | } |