0
I have a code in React that uses the hook useState in that way:
const [tarefas, setTarefas] = useState([]);
It is a task list code, every time I remove a project I have to update the project of each task, I was trying to do so:
setTarefas(tarefas.map(tarefa => {
if (tarefa.projeto > id) {
tarefa.projeto--;
}
return tarefa;
}
Whereas the id is the id of projeto that is being deleted. The problem is, it does not update the property projeto of tarefa, continues as if that part of the code did not exist. Does anyone have any idea what it might be?
Just before I try to do that, I do the filter in the array by means of that line:
setTarefas(tarefas.filter(tarefa => tarefa.projeto !== id));
What’s really happening is that it doesn’t seem to filter, the tasks don’t fade. It filters only if I take out the method that changes the id.
what you want to do I was in doubt?
– novic
you please put the layout of each task item!
– novic
i want in case change the id of the task object if it is larger than the id I passed
– Caio Grossi
project: current project, name: task.name, date: task.data, priority: task.priority, done: task.done
– Caio Grossi