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

134
Views
Show Image Condition inside a map

I am getting an array with objects from mongodb with react.js and create a ranking list with map, sorted by rating.

{album && album.map && album.map((d) =><Link className="link" to={{ pathname: "/itemPage/" + d.id, album: d}}>{d.isSingle? <ul className={"listNumber"}> <span className={"info"}>{i++}. {d.artist} - {d.title}<b className={"rating"}>{getRating(d)}</b></span>  </ul> : ""}</Link>)}

it works wonderfully and my list looks like this with 4 objects.

  1. Eminem - xxx 8.5
  2. Adele - xxx 7.0
  3. BMTH - xxx 6.3
  4. Eazy-E - xxx 3.0

Now I would like to include the condition, that the first 3 rankings should include a img. I save the img for each object, so it is easily accessible with

<img src={d.imgSmall}/>

the object looks like this.

artist: "Eminem"
id: "61a9474968f7d778e3ee73f4"
imgSmall: "https://i.scdn.co/image/ab67616d00001e0255f592593d746c4fd1fa5ae9"
isSingle: true
rating: 8.5
reviews: (2) [{…}, {…}]
title: "xxx"

My Problem is I can only make it work to have every entry include the img.

about 4 years ago · Juan Pablo Isaza
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!