Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda