I'm trying to make onClick effect on every item of .map method like this:
this.props.products.map(function(item, i) {
return (
<tr key={ i } onClick={ function() {
console.log(arrayForOnClick)
arrayForOnClick = [item['id'], item['name'], item['price']]
this.handleTableString(item['id'], item['name'], item['price'])
// Нужно передать айди, имя и цену в модальное окно при клике на этот <tr>.
} }>
<td>{ item['id'] }</td>
<td>{ item['name'] }</td>
<td>{ item['price'] }</td>
</tr>
)
}, this)
And I'm trying to access this.handleTableString which is
handleTableString(id, name, price) {
this.setState({
editProductModal: true,
selectedId: id,
selectedName: name,
selectedPrice: price
})
console.log('triggered')
}
But I get error Uncaught TypeError: Cannot read property 'handleTableString' of null
Is there another way to make that onClick or something is wrong with my code?