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

96
Views
Use data from an array as src path for an img

I receive an array like this from the backend :

['test.jpg', 'test2.jpg']

I put it into a React state named pictures.

What I need to do is to map on it, and for each picture name in the array, create an img with that name as variable in the path like this :

{pictures.map((picture) => (
<img
className="picture"
src={`http:localhost:8000/pictures/${ WHAT DO I NEED TO WRITE HERE ? }/>

)))}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The first argument from the map function refers to each item in your array, so name it whatever you want and you get the item from the array.

Since you have named it picture, the name of the each item is now picture

Briefly, you can put picture in the space as:

{pictures.map((picture) => (
  <img
    className="picture"
    src={`http:localhost:8000/pictures/${picture}`}/>
 ))}
about 4 years ago · Juan Pablo Isaza Report

0

In this case you would just need to add http:localhost:8000/pictures/${picture}

Of course this will only work as long as there is an image with a matching name on port 8000

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!