首页 > 解决方案 > 如何更新和删除 redux state reducer

问题描述

当我移动用户时,我想更新新组,reducer 并删除旧组中的用户

/mystate
// groups: [
//   {
//     users: [
//       '1A',
//       '1B'
//     ],
//     id: '2',
//     name: 'shoes'
//   },
//   {
//     users: [],
//     id: '1',
//     name: 't-shirt'
//   }
// ]

我的减速器显示了这一点,我不知道如何更新数据组

  //in action get id groups and group with id users
  // {
  //   type: 'UPDATE_GROUP',
  //   id: '1A',
  //   group: [
  //     '1'
  //   ]
  // }
  switch (action.type) {
    case UPDATE_GROUP:
      return {
        ...state,
        shop: {
          ...state.shop,
          groups: state.shop.groups ????
        }
      };
    default:
      return state;
  }
}```

标签: javascriptreactjsreduxupdates

解决方案


推荐阅读