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.
36 lines
1.4 KiB
36 lines
1.4 KiB
import _extends from "@babel/runtime/helpers/esm/extends"; |
|
import verifyPlainObject from '../utils/verifyPlainObject'; |
|
export function defaultMergeProps(stateProps, dispatchProps, ownProps) { |
|
return _extends({}, ownProps, stateProps, dispatchProps); |
|
} |
|
export function wrapMergePropsFunc(mergeProps) { |
|
return function initMergePropsProxy(dispatch, _ref) { |
|
var displayName = _ref.displayName, |
|
pure = _ref.pure, |
|
areMergedPropsEqual = _ref.areMergedPropsEqual; |
|
var hasRunOnce = false; |
|
var mergedProps; |
|
return function mergePropsProxy(stateProps, dispatchProps, ownProps) { |
|
var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps); |
|
|
|
if (hasRunOnce) { |
|
if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps; |
|
} else { |
|
hasRunOnce = true; |
|
mergedProps = nextMergedProps; |
|
if (process.env.NODE_ENV !== 'production') verifyPlainObject(mergedProps, displayName, 'mergeProps'); |
|
} |
|
|
|
return mergedProps; |
|
}; |
|
}; |
|
} |
|
export function whenMergePropsIsFunction(mergeProps) { |
|
return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined; |
|
} |
|
export function whenMergePropsIsOmitted(mergeProps) { |
|
return !mergeProps ? function () { |
|
return defaultMergeProps; |
|
} : undefined; |
|
} |
|
export default [whenMergePropsIsFunction, whenMergePropsIsOmitted]; |