📜  更新 React redux reducer 中的状态 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:26.601000             🧑  作者: Mango

代码示例2
case foodConstants.FOOD_SUCCESS_POST: {

  const updatedItems = state.items.map((food1) => {
    if (food1.id === action.id) {
      return { ...action };
    }

    return food1;
  });
 return { ...state, items: updatedItems };
}