Untitled

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

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

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

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

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

export default ImageFetcher;
Leave a Comment