I have a simple application. I have an upload which reads multiple images into a hook. From this I would then like to reduce and display each individual image. However, React only ever shows me one image
useEffect(() => {
const CallMe = async () => {
// files contains 2 images
if (files.length > 0) {
return Promise.all(
files.map(async (file, idx) => {
return new Promise(async (resolve, reject) => {
try {
const image = await resizeFile(file[idx]);
console.log(image);
resolve(image);
} catch (error) {
reject(error);
}
});
})
);
}
};
CallMe().then((res) => {
setThumbnails([...thumbnails, res]);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [files]);
{thumbnails.length &&
thumbnails?.map((img, idx) => {
if (img)
return (
//ONLY ONCE IS SHOWN
<img
key={idx}
src={img}
alt="soso"
height={100}
width={100}
></img>
);
})}
