I'm learning to use React and I have a problem about how to pass the id using a button.
I have recover data for my fetch from: https://jsonplaceholder.typicode.com/users
My js page:
handleClick(){
alert("ALERT " + this.props);
}
render(){
const listMeetings = this.props.meetings.map((meeting) =>
<li key={meeting.id}>{meeting.name}
<button key={meeting.id} onClick={() => this.handleClick(meeting.id)} value={meeting.id}>{'Details'}</button>
</li>);
return(
<div>
<ul>{listMeetings}</ul>
</div>
)
}
}
So at the moment I have a list of name and a button, immediately next to each name. What I would to do is to pass the id of every name, when the button is clicked (at the moment I would print only an alert with the id.
With my code, I have understand that I pass all the array (so I have 10 object).
How can I do? thank you.