How to add image in react by using parcel?
You need to do it like this
import image from 'path/to/image.png';
And then inside your react JSX
follow below code:
<img src={image} />
It is no different between <img src="path/to/image.png"/>
and <img src={"path/to/image.png"}/>
, you should import
your image and then use it like a JavaScript
object, see below:
import somePhoto from 'path/to/image.png';
You don't attend to 'path/to/image.png';
and wrote it like nothing. input your path in a quotation mark. Then inside your react
JSX
code write your img
tag like below:
<img src={somePhoto} />
There are more different ways. in other react
projects we use another server to load the images. but the specific images for application should be like above.