Skip to content
Advertisement

How to display every image inside an image folder in react

I have an image folder in my create-react-app project with a bunch of images. I want to display every single image in the components.

JavaScript

In my .jsx file, I want to loop over every image/icon and display it.

Icons.jsx

JavaScript

Advertisement

Answer

I had the same scenario where I have to pick images or SVGs from the folder and display it. Below is the process I followed :

Folder structure

JavaScript

In component where ever you want to consume the image there, you have to do this:

JavaScript

It worked for me; Give it a try.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement