import { useEffect, useState } from 'react'; import { useErrorHandler } from '../../hooks/useErrorHandler'; export default function GlobalErrorDisplay() { const { errors, clearError, clearAllErrors } = useErrorHandler('GlobalErrorDisplay'); const [isVisible, setIsVisible] = useState(false); useEffect(() => { setIsVisible(errors.length > 0); }, [errors.length]); if (!isVisible || errors.length === 0) { return null; } return (
{errors.map((error, index) => (
⚠️ {error.source}

{error.message}

{error.stack && (
Show stack trace
                    {error.stack}
                  
)}
))} {errors.length > 1 && ( )}
); }