lijianan
2 years ago
committed by
GitHub
2 changed files with 19 additions and 5 deletions
@ -0,0 +1,16 @@ |
|||
import React from 'react'; |
|||
import type { SizeType } from '../../config-provider/SizeContext'; |
|||
import SizeContext from '../../config-provider/SizeContext'; |
|||
|
|||
const useSize = <T extends string>(customizeSize?: T) => { |
|||
const size = React.useContext<SizeType>(SizeContext); |
|||
const mergeSize = React.useMemo<T>(() => { |
|||
if (!customizeSize) { |
|||
return size as T; |
|||
} |
|||
return customizeSize ?? size; |
|||
}, [customizeSize, size]); |
|||
return mergeSize; |
|||
}; |
|||
|
|||
export default useSize; |
Loading…
Reference in new issue