please delete the item using redux

My first question would be, in your deleteTask method what is being returned here? Does a delete method actually return the task you deleted?

.then(({ data: task }) => {
    dispatch({ type: DELETE_TASK, task })

If not, another way you can address this is by changing the task in your dispatch to the id you are passing to the deleteTask method:

dispatch({ type: DELETE_TASK, id });

Then use the filter method instead of map in your reducer to return the tasks that don’t match that deleted task’s id, effectively “deleting” it from your state:

  return {
     list: state.list.filter((it) => {
         return !==;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top