'use client'; import React from 'react'; import {createPortal} from 'react-dom'; import StaticAlert from '@/components/StaticAlert'; import {Alert} from '@/context/AlertProvider'; interface AlertStackProps { alerts: Alert[]; onClose: (id: string) => void; } export default function AlertStack({alerts, onClose}: AlertStackProps) { const [mounted, setMounted] = React.useState(false); React.useEffect(() => { setMounted(true); return () => setMounted(false); }, []); if (!mounted) return null; const alertContent = (
{alerts.map((alert, index) => (
onClose(alert.id)} />
))}
); return createPortal(alertContent, document.body); }