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

147
Vistas
Render img element for each of the IDs in multiple arrays

I'm getting the image IDs for gallery photos from reddit in this way:

// Check if post is a gallery and if yes, map through each image and get the id
if (post.is_gallery) {
  const id = post.gallery_data.items.map((item) => item.media_id);
  console.log(id);
}

I want to put each of these IDs in an <img /> element and render them, but the response I get from that if statement is like this:

enter image description here

How can I get each of those IDs from their arrays and render them in multiple <img > elements?

<img
  src={`https://i.redd.it/${id-goes-here}.jpg`}
  className="image"
  alt="Gallery Images"
/>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can map over your data and return an img tag like this:

const images = post.gallery_data.items.map((item) => <img src={`https://i.redd.it/${item.media_id}.jpg`} 
                                                          key={item.media_id} 
                                                          className="image" 
                                                          alt="Gallery Images"/>);

then you can put your images variable in your jsx, like this:

return (<>{images}</>)

Aslo you can put the map directly in your jsx rendering, like this:

  return (<>{post.gallery_data.items.map((item) => <img src={`https://i.redd.it/${item.media_id}.jpg`} 
                                                        key={item.media_id} 
                                                        className="image" 
                                                        alt="Gallery Images"/>
              }</>);
about 4 years ago · Juan Pablo Isaza Denunciar
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