L
L
lukman_q2021-04-30 01:11:12
React
lukman_q, 2021-04-30 01:11:12

How to load images in a loop?

Hello, new to react, I have an array like this

[{
        img_from:0,
        name:'hello',
                                img:'some.jpg'
      },
      {
        img_from:0,
        name:'hello',
                               img:'some.jpg'
      }
      ]

and I need to display the code with the image through the html loop, how to set the path if I don’t know which images will be used
array.map(function(elem, index) {
      return<div className="catalog-item">
       <img src="тут должно быть локальное изображение">
        </div>
})

how to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ice, 2021-04-30
@IceRD

the pictures are located in the same folder, what prevents you from specifying the path and dynamically substituting the file name?
or pass the full path to the image

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question