async-modal-react
Version:
A React modal that can be used with Promise.
27 lines (26 loc) • 733 B
TypeScript
import { Dispatch, FunctionComponent, SetStateAction } from "react";
export interface ModalProps {
close: () => void;
resolve: <Result = any>(v: Result) => void;
reject: <Reason = any>(reason: Reason) => void;
}
export interface ModalOptions {
onClickOutsideClose?: boolean;
disableScroll?: boolean;
enableInsideScroll?: boolean;
errorOnClose?: boolean;
}
export interface ModalType<P = any> extends ModalProps {
id: number;
component: FunctionComponent<P>;
props: P;
options?: ModalOptions;
}
export interface ModalContextProps {
modals: ModalType[];
setModals: Dispatch<SetStateAction<ModalType[]>>;
modalIdRef: {
current: number;
};
errorOnClose: boolean;
}