Don't mutate props. Instead emit an event and do that in the parent component.
$emit('remove', z);
And in your parent component
<child :todoDetails="todoDetails" @remove="todoDetails.splice(z, 1)" />
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Here is my method:
async deleteTodo(id) {
try {
res = await axios.delete(`todo/${id}`);
let z = this.todoDetails
.map((todoDetails) => todoDetails.id)
.indexOf(id);
this.todoDetails.splice(z, 1);
console.log("RES: " + res);
} catch (error) {
console.log(error);
}
// this.isOpen = true;
// this.isEdit = true;
},
but because I am inside a child component, I am getting: Unexpected mutation of "todoDetails" prop
Don't mutate props. Instead emit an event and do that in the parent component.
$emit('remove', z);
And in your parent component
<child :todoDetails="todoDetails" @remove="todoDetails.splice(z, 1)" />
Please or to participate in this conversation.