import React from 'react'; import type { SizeType } from '../SizeContext'; import SizeContext from '../SizeContext'; const useSize = (customSize?: T | ((ctxSize: SizeType) => T)): T => { const size = React.useContext(SizeContext); const mergedSize = React.useMemo(() => { if (!customSize) { return size as T; } if (typeof customSize === 'string') { return customSize ?? size; } if (customSize instanceof Function) { return customSize(size); } return size as T; }, [customSize, size]); return mergedSize; }; export default useSize;