Skip to content
Advertisement

Sending the id of the respective component through a click

I am trying to send the id of the respective object through an on-click event , yet I always end up being sent the synthetic onClick event , how can I change this ? How my array of objects looks like :

JavaScript

My onClick={(id)=>handleOpen(id)}

EDIT: It was recommended to change the renderig of the button in the following way :

JavaScript

Thank you very much !

Advertisement

Answer

you can also do like that so when ever your items got update the map function adjust all index automatically

JavaScript

In render

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