I created a functional component in which i get data from Django REST and I want to manage deleting items. When I write a proper function I get the error
Cannot read property 'deleteItem' of undefined
I guess it is because I don't have a constructor here, am I right?
This is my function:
function deleteItem(id) {
axios.delete('http://127.0.0.1:8000/api/products' + `/${id}/`);
};
And I want to use it here:
<Button variant="dark" onClick={()=>this.deleteItem(product.id)} >Delete</Button>