I'm trying to make an editable list in React with an option to delete some entries. Editing works as intended:
function handleChange(i){
let newArr = [...entries];
newArr[i].body = event.target.value;
setEntries(newArr);
}
But if I try to implement deleting:
let newArr = [...entries];
newArr.splice(i, 1);
setEntries(newArr);
React throws the following error:
Rendered fewer hooks than expected. This may be caused by an accidental early return statement.
I'm new to React so probably it's something obvious, therefore my apologies for the question. I honestly googled for quite a long time before asking :) Any suggestions would be greatly appreciated!