Delete an item from Redux state

后端 未结 5 1646
庸人自扰
庸人自扰 2021-01-30 17:44

I\'m wondering if you could help me with this problem if possible. I am trying to delete an item from the Redux state. I have passed in the ID of the item that the user clicks v

5条回答
  •  臣服心动
    2021-01-30 18:41

    You can use Try this approach.

    case "REMOVE_ITEM": 
      return {
      ...state,
        comment: [state.comments.filter(comment => comment.id !== action.id)]
      }
    

提交回复
热议问题