ant-design/components/config-provider/SizeContext.tsx
lijianan 9d1854763d
refactor: add useSize replace React.useContext (#42282)
* refactor: add useSize

* fix

* fix

* fix

* fix

* fix
2023-05-12 14:53:47 +08:00

19 lines
531 B
TypeScript

import * as React from 'react';
import useSize from './hooks/useSize';
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 mergedSize = useSize(size);
return <SizeContext.Provider value={mergedSize}>{children}</SizeContext.Provider>;
};
export default SizeContext;