Zack Chang
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
3 deletions
-
components/config-provider/SizeContext.tsx
|
|
@ -1,5 +1,4 @@ |
|
|
|
import * as React from 'react'; |
|
|
|
import useSize from './hooks/useSize'; |
|
|
|
|
|
|
|
export type SizeType = 'small' | 'middle' | 'large' | undefined; |
|
|
|
|
|
|
@ -11,8 +10,8 @@ export interface SizeContextProps { |
|
|
|
} |
|
|
|
|
|
|
|
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => { |
|
|
|
const mergedSize = useSize(size); |
|
|
|
return <SizeContext.Provider value={mergedSize}>{children}</SizeContext.Provider>; |
|
|
|
const originSize = React.useContext<SizeType>(SizeContext); |
|
|
|
return <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>; |
|
|
|
}; |
|
|
|
|
|
|
|
export default SizeContext; |
|
|
|