79345064

Date: 2025-01-10 08:46:15
Score: 0.5
Natty:
Report link

I found a solution myself.

const GifCard = ({
  gif,
  onClick
}: {
  gif: Gif;
  onClick: (gif: Gif) => void;
}) => {
  const [isLoading, setIsLoading] = useState(true);

  return (
    <>
      <Skeleton
        w="100%"
        maw={160}
        radius="xs"
        aria-label="gif skeleton"
        h={gif.media_formats.gif.duration > 3 ? 160 : 90}
        style={{ display: isLoading ? 'block' : 'none' }}
      />

      <Image
        src={gif.media_formats.gif.url}
        w="100%"
        maw={160}
        radius="xs"
        alt="GIF"
        onLoad={() => setIsLoading(false)}
        style={{ display: isLoading ? 'none' : 'block' }}
        onClick={() => onClick(gif)}
      />
    </>
  );
};
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Sujal