I'm using react hooks and i trying to send the value to function delete and to do function put
<Fab aria-label="delete"
className={classes.fab}
value={vacation.id}
key={vacation.id}
onChange={setDeleteid(vacation.id)}
onClick={DeleteCard}>
<DeleteIcon />
</Fab>
this is the function
const DeleteCard = (e) => {
e.preventDefault();
console.log('delete' + deleteid);
alert(deleteid)
const confirm = window.confirm(`You are sure you want to delete vacation number ?`);
if (confirm == true) {
await axios.delete(`http://localhost:4000/users/admin/delete/:${e}`)
} else {
alert("You pressed Cancel!")
}
}
this is the my state
//vacation
const [vacation, setVacation] = useState([]);
const [deleteid, setDeleteid] = useState();
//putcard
const [description, setDescription] = useState("");
const [destination, setDestination] = useState("");
const [fromDate, setFromDate] = useState("");
const [toDate, setToDate] = useState("");
const [price, setPrice] = useState("");
Apparently the id I'm trying to send to state doesn't come in because it records me undifind
UPDATE
This is my state
const [deleteid, setDeleteid] = useState('');
Here I want to send and it gives me undefined
onChange={() => setDeleteid(value)}