-2

I have a basic React app set up using the Create-React-App tool.

I have an images in my images folder: /src/img/logo.png

I am including it in one of my component JS files (let's say it's located at /src/Login.js) like this:

import logo from "../img/logo.png";

I am embedding them into my code like this:

<img src={logo} />

When I look at the rendered page, I see that the "src" attribute of this image has a data URI. How can I get the app to generate a URL for this image instead of a data URI?

Rob
  • 14,746
  • 28
  • 47
  • 65
Cog
  • 1,545
  • 2
  • 15
  • 27

1 Answers1

1

Why are you importing image with import, you can directly use path or take that path in one variable and than pass it to the src like this:

 var imgUrl = "../img/logo.png"; 

 <img src={imgUrl} />