'In this code, delete action works perfectly but page doesn't show the update without a reload, how can I use state/effect to solve the issue here?
The page doesn't show the updated data without a reload, how can I solve the issue?
const handleDeleteItem = id => {
const deletion = window.confirm('Do you really want to delete the item?');
if(deletion){
const url = `http://localhost:5000/items/${id}`;
fetch(url, {
method: 'DELETE',
headers: {
'content-type': 'application/json'
},
})
.then(res=>res.json())
.then(data =>{
console.log(data);
toast.success('Item has been deleted successfully')
})
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
