I am trying to fetch images from Firebase storage and then display them in my react app. Currently, there are 4 images in my storage and want to display all.
Fetch 4 different images from storage properly but displayed first image(1.png) 4 times.
useEffect(() => {
const fetchImages = async () => {
let result = await storageRef.child('images').listAll();
let urlPromises = result.items.map(imageRef => imageRef.getDownloadURL());
return Promise.all(urlPromises);
}
const loadImages = async () => {
const urls = await fetchImages();
setFiles(urls);
}
loadImages();
}, []);
am I using map wrong?
<div>
{files.map((index) => (
<img key={index} src={files} />
))}
</div>

<img key={index} src={index} />, setting src tofilesincorrect