Skip to content
Advertisement

How do I associate seperate state to each button?

Hello

I am trying to associate a like button with each PaperCard component as shown in the code below. I have included the relevant code. Currently, The like button shows up and every time you click it the counter increases BUT all the buttons share the same state. So I am trying to fix that. I am new to JS and React.

Any help will be appreciated. Thanks!

JavaScript

Advertisement

Answer

The element from the map callback is extracted as a component, and now every button has its own state.

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