i wonder how i can pass as parameter to onClick function react list element
here is my list.
const items = this.state.tableData.items.map(
(item, index) => <td key={index} onClick={this.getItem}>{item.name}</td>
);
here is i define my function
constructor(props) {
super(props);
this.state = {
tableData: this.props.items
};
this.getItem = this.getItem.bind(this);
}
here is my function.
getItem(item) {
console.log(item)
}
I wan't to get item details onClick to item where i render my list.
i tried to make onClick={this.getItem(item)} i get with this way item details but not at onClick. Just all items details console logged when i open my page.
what can i do ?