mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 07:09:55 +08:00
ac5a06027e
This reverts commit ea8ed28209
.
22 lines
577 B
TypeScript
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;
|