import { useState } from 'react'; import { ImageOff } from 'lucide-react'; declare module 'react' { interface ImgHTMLAttributes extends React.HTMLAttributes { fetchpriority?: 'high' | 'low' | 'auto'; } } interface ImageWithFallbackProps { src: string; alt: string; className?: string; sizes?: string; loading?: 'lazy' | 'eager'; fetchpriority?: 'high' | 'low' | 'auto'; } const ImageWithFallback: React.FC = ({ src, alt, className = '', sizes = '100vw', loading = 'lazy', fetchpriority = 'auto' }) => { const [error, setError] = useState(false); const [isLoading, setIsLoading] = useState(true); if (error) { return (
{alt}
); } return (
{isLoading && (
)} {alt} setIsLoading(false)} onError={() => setError(true)} decoding="async" />
); }; export default ImageWithFallback;