ant-design/components/config-provider/SizeContext.tsx
lijianan 59a332bf47
chore: use React.useContext() replace <Context.Provider /> (#39950)
* chore: use React.useContext() replace <Context.Provider />

* fix

* fix

* fix

* fix

* fix
2023-01-01 21:17:05 +08:00

18 lines
526 B
TypeScript

import * as React from 'react';
export type SizeType = 'small' | 'middle' | 'large' | undefined;
const SizeContext = React.createContext<SizeType>(undefined);
export interface SizeContextProps {
size?: SizeType;
children?: React.ReactNode;
}
export const SizeContextProvider: React.FC<SizeContextProps> = ({ children, size }) => {
const originSize = React.useContext<SizeType>(SizeContext);
return <SizeContext.Provider value={size || originSize}>{children}</SizeContext.Provider>;
};
export default SizeContext;