My backend API have mulitple file upload. User can have choice to upload one image or multiple or none. So, image array may be length 0, 1 or more.
Scenerio:
endpoint api/v1/img/1 may have gallery img1, img2, img3
endpoint api/v1/img/2 may have gallery img1
endpoint api/v1/img/3 may have gallery null
{ gallery.img_urls?.map((img, i) => (
<div key={i}>
<img src={img} alt="gallery" />
</div>
))}
It is displaying mulitiple image. But if image isn't present it raise an error
ref3.map is not a function