use handleClick
instead of this.handleClick
.Because functional component not have this
. And also declare the function handleClick
outSide the useEffect
not necessary to use inside
updated
You are declare do many function . just remove delTodo
function and add async to handleClick
const handleClick = async (todo_id) => {
const del = await Axios.delete('http://localhost:3001/todo/' + todo_id)
.then(() => {
console.log('deletado!!')
})
}
<button key={i++} id="del" onClick={() => {handleClick(todo._id)}}/>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…