ant-design/components/config-provider/DisabledContext.tsx
lijianan 28d1157d6b
type: optimization undefined type (#40241)
* type: optimization undefined type

* fix type

* fix type

* add

* revert

* revert

* revert
2023-01-16 09:55:52 +08:00

22 lines
577 B
TypeScript

import * as React from 'react';
export type DisabledType = boolean | undefined;
const DisabledContext = React.createContext<DisabledType>(false);
export interface DisabledContextProps {
disabled?: DisabledType;
children?: React.ReactNode;
}
export const DisabledContextProvider: React.FC<DisabledContextProps> = ({ children, disabled }) => {
const originDisabled = React.useContext(DisabledContext);
return (
<DisabledContext.Provider value={disabled ?? originDisabled}>
{children}
</DisabledContext.Provider>
);
};
export default DisabledContext;