import { createContext, ReactNode, useState } from 'react'; import CloseIcon from '@material-ui/icons/Close'; function ToastArea(props: { children?: ReactNode; rerender?: boolean; }) { return
{props.children}
; } function Toast(props: { text?: string; description?: string; icon?: ReactNode; children?: ReactNode; type?: 'normal' | 'confirmation' | 'error'; }) { var [visible, setVisibility] = useState(true); setTimeout(() => setVisibility(false), 10e3); return visible &&
{props.children ||
{props.icon}

{props.text}

{props.description}

setVisibility(false)} >
}
; } export type toastSettings = { message: string; description?: string; type: 'confirmation' | 'normal' | 'error'; icon?: ReactNode; }; export type toastType = (settings: toastSettings) => void; export var ToastContext = createContext<{ toast?: toastType; }>({}); var toasts: Array = []; export function ToastContextWrapper(props: { children?: ReactNode; }) { var [dummyState, rerender] = useState(false); return { toasts.push( , ); rerender(!dummyState); }, }} > {props.children} {toasts} ; }