import { Image, Loader, createStyles } from '@mantine/core';
import { useDebouncedValue } from '@mantine/hooks';
import { IconPhotoOff } from '@tabler/icons';
interface DebouncedImageProps {
width: number;
height: number;
src: string;
debouncedWaitPeriod?: number;
}
export const DebouncedImage = ({
src,
width,
height,
debouncedWaitPeriod = 1000,
}: DebouncedImageProps) => {
const { classes } = useStyles();
const [debouncedIconImageUrl] = useDebouncedValue(src, debouncedWaitPeriod);
if (debouncedIconImageUrl !== src) {
return ;
}
if (debouncedIconImageUrl.length > 0) {
return (
}
className={classes.iconImage}
src={debouncedIconImageUrl}
width={width}
height={height}
fit="contain"
alt=""
withPlaceholder
/>
);
}
return (
);
};
const useStyles = createStyles(() => ({
iconImage: {
objectFit: 'contain',
},
}));