score:6

Accepted answer

With your setImages({ images: imageArray }) call, you'll get value of images const to be:

images = {images: [...]} // [...] is the imageArray

so you'll have to access it as images.images, or rather set it as setImages(imageArray) which will be accessible as you expect.

Also, access the state variable and use map instead of forEach, not the imageArray. So instead of imageArray.forEach(...) use images.map(...). Map returns an array with values returned from the function calls. Whereas forEach returns undefined.

score:0

{imageArray.length>0 ? 
<div>
  {imageArray.map((element)=>{
  return(
    <img src={element} alt="" />
    )
  })}
</div>
:null}

Hope this solves


Related Query

More Query from same tag