I have created a table that automaticly adds all the products from the database:
<tbody>
{allproducts.map(allproducts =>
<tr key={allproducts.id}>
<td>{allproducts.title}</td>
<td>{allproducts.price}</td>
<td>{allproducts.quantity}</td>
<td> <button className="DeleteButton" onClick=({this.deleteProduct({allproducts.id}) }) }) >delete</button></td>
</tr>
)}
</tbody>
it is about this part:
<td> <button className="DeleteButton" onClick=({this.deleteProduct({allproducts.id}) }) >delete</button></td>
i want to pass the “id” into the function
i remmber in javascript it was as simple as
DeleteButton.setAttribute("onclick", `deleteProduct(${item.id})`);
how do i achive this with reactjs?