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.
54 lines
1.8 KiB
54 lines
1.8 KiB
"use strict"; |
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"]; |
|
|
|
exports.__esModule = true; |
|
exports["default"] = void 0; |
|
exports.defaultMergeProps = defaultMergeProps; |
|
exports.whenMergePropsIsFunction = whenMergePropsIsFunction; |
|
exports.whenMergePropsIsOmitted = whenMergePropsIsOmitted; |
|
exports.wrapMergePropsFunc = wrapMergePropsFunc; |
|
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); |
|
|
|
var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject")); |
|
|
|
function defaultMergeProps(stateProps, dispatchProps, ownProps) { |
|
return (0, _extends2["default"])({}, ownProps, stateProps, dispatchProps); |
|
} |
|
|
|
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') (0, _verifyPlainObject["default"])(mergedProps, displayName, 'mergeProps'); |
|
} |
|
|
|
return mergedProps; |
|
}; |
|
}; |
|
} |
|
|
|
function whenMergePropsIsFunction(mergeProps) { |
|
return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined; |
|
} |
|
|
|
function whenMergePropsIsOmitted(mergeProps) { |
|
return !mergeProps ? function () { |
|
return defaultMergeProps; |
|
} : undefined; |
|
} |
|
|
|
var _default = [whenMergePropsIsFunction, whenMergePropsIsOmitted]; |
|
exports["default"] = _default; |