Imagefetch.jsx

Imagefetch.jsx
mail@pastecode.io avatar
unknown
plain_text
a month ago
932 B
2
Indexable
Never
import React, { useEffect, useState } from 'react';
import "./FetchImage.css"
const ImageFetcher = () => {
  const [fetchedImages, setFetchedImages] = useState([]);

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

    // Parse stored base64 strings and convert them back to images
    if (storedImages) {
      const base64Images = JSON.parse(storedImages);
      setFetchedImages(base64Images);
    }
  }, []);

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

export default ImageFetcher;
Leave a Comment