S
S
Sergey750il2022-02-17 22:20:35
React
Sergey750il, 2022-02-17 22:20:35

How to change src of iframe when rendering via map?

Hello. Through the map, several dozens of items blocks are displayed, but how can I make sure that when clicked, the src attribute changes only for the block that is in the same parent (item.) Now, when clicked, the event fires simultaneously on the entire list of blocks. If I did it on Vue, I tried ref, but it didn’t work out here.

<div class="item">
          <div onClick={() => handlePlay(id)}>
                  Запуск {id}</div>
                  <iframe id="ytplayer" width="640" height="360" src={video} frameborder="0" />
</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question