I'm new to react and now I'm trying to make the delete alert as a modal, can anyone tell me where do I put it?
const handleDelete = (id) => {
const confirm = window.confirm("Delete this ?");
if(confirm) {
axios.delete('https://64d9e02de947d30a380a6a16.mockapi.io/todos/' +id)
.then(res => {
navigate("/");
})
.catch(err => console.log(err));
}
}
return (
<div>
<thead>
<tr>
<th>name</th>
</thead>
<tbody>
<tr>
<td>{data.id}</td>
<td>
<button onClick={e => handleDelete(data.id)} className='btn btn-sm'>Delete</button>
</td>
</tr>
You can do like this:
This is an example you can modify according to your need.