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

246
Vistas
Images not loading in react while looping even after using require

I have created an array with title and images but when I am using the map to extract the image, the image path is getting printed as a string. I also tried using require keyword but the error is coming stating "require is not defined".I also tried moving my assets(images) into the src folder but that is also not working. I am using snowpack.

const Img = [
  [
    {
      title: "Recommended to you",
      img: "assets/images/badging2.jpg"
    },
  ],
  
  [
    {
      title2: "hello",
      img1 : "../../public/assets/images/badging7.jpg"
    },
  ]
];

export default Img;

This is my map function:-

     <div>
         {Img[0].map((item) => {
           return <p>{item.img}</p> 
          })}
    </div>   

// output - assets/images/badging2.jpg
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try returning like this return <img src={item.img} />

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