import React, { useState } from 'react'; import { Box, BoxProps } from './primitives/Box'; import { ImagePlaceholder } from './ImagePlaceholder'; export interface ImageProps extends Omit, 'children'> { src: string; alt: string; fallbackSrc?: string; fallbackComponent?: React.ReactNode; } export const Image = ({ src, alt, fallbackSrc, fallbackComponent, ...props }: ImageProps) => { const [error, setError] = useState(false); if (error) { if (fallbackComponent) return <>{fallbackComponent}; if (fallbackSrc) return ; return ; } return ( setError(true)} {...props} /> ); };