New Jan 17, 2026

About React with setState [duplicate]

Libraries, Frameworks, etc. All from Newest questions tagged reactjs - Stack Overflow View About React with setState [duplicate] on stackoverflow.com

I have a component ResultComponent and I wanted whenever I click "Edit" button, I will get the result of the value of attribute data-id and store it in state (property idClicked). I have initial value of the state.idClicked (I set it as null).

Now is the problem, when I first click it will alway return null value, the second try return expected value. Now I want it will return the right value on the first click.

Here is my code and my result:

Scroll to top