Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
684 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('Images');

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

  return (
    <div>
      <h2>Fetched Images</h2>
      {fetchedImages.map((image, index) => (
        <img key={index} src={image.dataURL} alt={`Image ${index}`} />
      ))}
    </div>
  );
};

export default ImageFetcher;
Leave a Comment