重置redux商店的一部分

时间:2018-02-19 16:35:12

标签: reactjs redux

我正在从应用程序注销用户并需要从状态中清除一些用户相关数据,查找我发现Dan Abramov的这个很棒的答案 How to reset the state of a Redux store?字面意思。

最后我做的是分解当前状态,然后将用户关联状态设置为undefined,如下所示:

if (action.type === 'RESET_STORE') {
  state = {...state,
    customer: undefined,
    cart: undefined,
    course: undefined,
  }
}

仅保留州的某些部分是个好主意吗?

0 个答案:

没有答案
相关问题