import { useState, useEffect } from 'react'; interface GalleryThumbnailProps { id: string; onSelect: (id:string) => void; } const GalleryThumbnail = ({ id, onSelect }: GalleryThumbnailProps) => { const [galleryId, setGalleryId] = useState(id); const [thumbnailUrl, setThumbnailUrl] = useState(''); const [isLoading, setIsLoading] = useState(true); const openGallery = () => { onSelect(galleryId); }; const getData = async () => { setIsLoading(true); const thumbnailResponse = await fetch('/api/galleries/'+galleryId+'/thumbnail'); const thumbnailUrl = await thumbnailResponse.text(); setThumbnailUrl(thumbnailUrl); setIsLoading(false); } useEffect(() => { getData(); }, []); return (
{!isLoading && }
); } export default GalleryThumbnail;