i created a table in React.js, also I use Firebase for data storage, here is my table code
{tableData.map((row, index) => {
return (
<tr key={row + index}>
{row.map((cell, index) => {
return (
<td key={"cell_" + index} onClick={() => this.handleClick(this.state.userSurname)}>{cell}</td>
);
})}
</tr>
);
})}
and here is my this.setState:
componentDidMount() {
db.onceGetUsers().on("child_added", snap =>{
var username = snap.child("name").child("name").val();
var surname = snap.child("name").child("surname").val();
this.setState({ users: this.state.users.concat([username])});
this.setState({ userSurname: this.state.userSurname.concat([surname])})
})
}
Here is my handleClick function:
handleClick(event){
alert(event)
}
So.. here is my problem, alert dialog displays every user surname, and what I'm trying to do is to display surname of user that is clicked in table.. how can i do that? :)