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

244
Views
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 answers
Answer question

0

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

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!