mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 22:48:29 +08:00
20 lines
518 B
TypeScript
20 lines
518 B
TypeScript
import * as React from 'react';
|
|
|
|
const DisabledContext = React.createContext<boolean>(false);
|
|
|
|
export interface DisabledContextProps {
|
|
disabled?: boolean;
|
|
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;
|