The deleteHandler is very messy. Could have been something like that:
deleteHandler
const deleteHandler = (e) => { const id = e.target.parentNode.id; const updatedTasks = tasks .filter((task) => { return task.id !== id }) .reduce((acc, curr) => { const last = acc[acc.lenght - 1] if (!last) return [curr] return [...acc, { ...curr, order: last.order + 1, }] }, []) // Update tasks setTasks([...updatedTasks]); setTask((prevTask) => ({ text: "", order: prevTask.order - 1, id: uniqid() })); };
Highly appreciated feedback ! The deleteHandler should be that simple as you pointed
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The
deleteHandler
is very messy. Could have been something like that:Highly appreciated feedback ! The
deleteHandler
should be that simple as you pointed