When I click in the space around the icon,The button works correctly and the post get deleted.But when clicked on the icon (<DeleteOutlineOutlinedIcon />), the post doesn't get deleted.As the name of the button is props.id, when I log the name, it shows undefined, I also tried to give the same name to the icon, but still it doesn't work.
<button name={props.id} onClick={deletePost}><DeleteOutlineOutlinedIcon /></button>
This is the deletePost function
function deletePost(e){
e.preventDefault();
if(window.confirm("Are you sure to delete"))
{
let {name} = e.target;
console.log(name);
$.post("http://localhost:4000/delete" , {name})
.done(res=>{
setAll({value:res});
console.log(allPosts);
})
.fail(e=>{console.log(e);})
}
}