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