diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-21 12:20:28 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-21 12:20:28 +0100 |
commit | 7c296536cae54a645e075b1e00bcd3d34d494bb9 (patch) | |
tree | 084dfff28b8f310e326a59c6350338033fc6d39b /components | |
parent | de522de148edd2e36ce4e7d911a343a3caf2c833 (diff) |
DOM -> toast :tada:
Diffstat (limited to 'components')
-rw-r--r-- | components/toast.tsx | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/components/toast.tsx b/components/toast.tsx index 5bfc0ae..d774c96 100644 --- a/components/toast.tsx +++ b/components/toast.tsx @@ -75,17 +75,14 @@ function Toast(props: { </div> } -export var ToastContext = createContext<{ toast?: (message: string, - type: "confirmation"|"normal"|"error", - icon?: ReactNode ) => void }>({}); +export type toastType = (message: string, type: "confirmation"|"normal"|"error", icon?: ReactNode ) => void; +export var ToastContext = createContext<{ toast?: toastType }>({}); var toasts: Array<JSX.Element> = []; export function ToastContextWrapper(props: { children?: ReactNode }) { var [dummyState, rerender] = useState(false); - return <ToastContext.Provider value={{ toast: (message: string, - type: "confirmation"|"normal"|"error", - icon?: ReactNode ) => { + return <ToastContext.Provider value={{ toast: (message, type, icon? ) => { toasts.push(<Toast type={type} text={message} icon={icon}/>); rerender(!dummyState); } }}> |