Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
917 B
1
Indexable
Never
import React, { useEffect, useState } from 'react';

const ImageFetcher = () => {
  const [fetchedImages, setFetchedImages] = useState([]);

  useEffect(() => {
    const fetchAndDecompressImages = async () => {
      // Fetch stored images from local storage
      const storedImages = localStorage.getItem('uploadedImages');

      // Parse stored base64 strings
      if (storedImages) {
        const base64Images = JSON.parse(storedImages);
        setFetchedImages(base64Images);
      }
    };

    fetchAndDecompressImages();
  }, []);

  return (
    <div className="image-grid-container">
      <h2>Fetched Images</h2>
      <div className="image-grid">
        {fetchedImages.map((imageSrc, index) => (
          <div key={index} className="image-item">
            <img src={imageSrc} alt={`Uploaded ${index}`} />
          </div>
        ))}
      </div>
    </div>
  );
};

export default ImageFetcher;
Leave a Comment