UNPKG

matrix-react-sdk

Version:
32 lines (31 loc) 1.3 kB
import { ReactNode } from "react"; /** * A ToastContext helps components display any kind of toast message and can be provided * by a parent component such that their children can display toasts, eg. a settings dialog * can provide a ToastContext such that controls within it can display toasts at the bottom * of the dialog. * * It is not (at time of writing) used by the *other* toasts that appear in the top right * corner of the app, however the name 'toast' as used in this class refers to the component * of the same name in compound that it is written to manage. */ export declare const ToastContext: import("react").Context<any>; /** * Returns the ToastRack in context in order to display toasts */ export declare function useToastContext(): ToastRack; /** * For components that wish to display toasts, return the currently active toast and * the ToastRack object that should be provided to the context */ export declare function useActiveToast(): [ReactNode | undefined, ToastRack]; type RemoveCallback = () => void; export declare class ToastRack { private currentToast; private updateCallback?; private idSeq; setCallback(cb: () => void): void; displayToast(contents: ReactNode): RemoveCallback; getActiveToast(): ReactNode | undefined; } export {};