import { useAtomValue } from "jotai"; import { AnimatePresence } from "motion/react"; import type { ReactNode } from "react"; import { hideToast, toastsAtom } from "../lib/toast"; import { Toast, type ToastProps } from "./core/Toast"; import { ErrorBoundary } from "./ErrorBoundary"; import { Portal } from "./Portal"; export type ToastInstance = { id: string; uniqueKey: string; message: ReactNode; timeout: 3000 | 5000 | 8000 | (number & {}) | null; onClose?: ToastProps["onClose"]; } & Omit; export const Toasts = () => { const toasts = useAtomValue(toastsAtom); return (
{toasts.map((toast: ToastInstance) => { const { message, uniqueKey, ...props } = toast; return ( hideToast(toast)} > {message} ); })}
); };