Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Find and get first valid image url from array React

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

use react-image and pass the array of the urls as src.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!