You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

21 lines
577 B

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;