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

172
Views
Getting broken image icon when displaying image from online url in ReactJS

The webpage display is fine otherwise. but the images show up like this.

my code is <img src = {props.imageUrl} /> and console.log(prop) returns

{...imageUrl: "https://unsplash.com/photos/3PeSjpLVtLg"...}

What could be the problem? Thank you!

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

0

The url is a web page. It is not a url to an image so an image tag won't be able to display it. In the case of this specific image, you want the url to be this:

https://images.unsplash.com/photo-1601439678777-b2b3c56fa627?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80
about 4 years ago · Juan Pablo Isaza Report

0

Try adding the require to the src image like this:

<img src = { require(props.imageUrl)} />

Another way around would be in the props adding the require :

Example:

 const slides = {
 imageUrl: require('url'),
}

and leave your code as it is in the <img src = {props.imageUrl} />

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!