I have mainImage and array of images. I need to check if mainImage is available first, if it's not, then I need to find first valid image in array of image urls and set it to image src. how can I achieve this?
const imageSrc= () => { const validImg = images.find(image => image.url); return mainImage?.url || validImg }
I need something like that to return main image if it's available or first resolved image from array. Thanks in advance
use react-image and pass the array of the urls as src.