How to use Image from Public Folder in a React
In this blog, we will learn how to use images from the public folder, if we use a lot of images static in our project then the public folder is best suitable to put an image because we can easily access the file from the public folder, there is no need to import a file.
Let’s see the following steps on how to use an image from a public folder in a react:
Use Image from Public Folder
- Create a folder named images inside the public folder.
- Put your image inside the images folder.
- Write the following code in your javascript file where you want to use image:
-
<img src={process.env.PUBLIC_URL+"images/logo.png"} />