import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { dismissToast, subscribeToasts, type Toast } from '../lib/toasts'; // The stack of toasts (lib/toasts.ts), mounted once in the layout. export function Toasts() { const [toasts, setToasts] = useState([]); useEffect(() => subscribeToasts(setToasts), []); if (toasts.length === 0) return null; return (
{toasts.map((toast) => (
{toast.text} {toast.action && ( dismissToast(toast.id)}> {toast.action.label} )}
))}
); }