amis-rpc-design/node_modules/antd/es/config-provider/hooks/useSize.js
2023-10-07 19:42:30 +08:00

19 lines
534 B
JavaScript

import React from 'react';
import SizeContext from '../SizeContext';
const useSize = customSize => {
const size = React.useContext(SizeContext);
const mergedSize = React.useMemo(() => {
if (!customSize) {
return size;
}
if (typeof customSize === 'string') {
return customSize !== null && customSize !== void 0 ? customSize : size;
}
if (customSize instanceof Function) {
return customSize(size);
}
return size;
}, [customSize, size]);
return mergedSize;
};
export default useSize;