Untitled

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

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

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

    // Parse stored images if available
    if (storedImages) {
      const parsedImages = JSON.parse(storedImages);
      setFetchedImages(parsedImages);
    }
  }, []);

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

export default ImageFetcher;
Leave a Comment