Reputation: 21
I searched and found that I was supposed to use require() but it doesn't seem to be working.
<img src={require("../assets/img/business.png")} alt="business" />
I can confirm that this image path is correct, but on the inspect mode it says the src of my image is [object Module].
Also, when I import the image from the same path, it works completely fine.
Could this be because I am using typescript? I also saw people talking about browserify on another post, does browserify have anything to do with me being unable to use require?
Upvotes: 1
Views: 4030
Reputation: 56
I believe you might need some sort of a loader for to tell your code how to process the image.
Have a look at these following libraries
Upvotes: 0
Reputation: 126
Can u try using .default
?
<img src={require("../assets/img/business.png").default} />
Upvotes: 6