E
E
Elrock2021-02-05 10:27:12
React
Elrock, 2021-02-05 10:27:12

How to change one button among button list on click?

Let's say there is an array with 12 objects and they are shown on the page with the following code

<ul>
  {arr.map((item, index )=> (
    <li key={index} >
      <h1>{item.title}</h1>
      <button>Click</button>
    </li>
  )}
</ul>

When you click on some button, you need to change the text of the button that was clicked, but how to do this if they are all the same and the onClick action will be applied to all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fedor, 2021-02-05
@Elrock

Check out this thread.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question