我正在尝试将一个对象添加到减速器中的数组中,然后,我想按日期对其进行排序(我可以尝试按顺序插入,但我认为或多或少是相同的努力)。
我正在使用 immer 来处理减速器的不变性:
const newState = produce(prevState, (draftState) => {
console.log(draftState);
draftState.status = COMPLETE;
draftState.current.entries.push(json.data);
if (json.included) draftState.current.included.push(json.included);
});
return { ...initialState, ...newState };
console.log 显示正在打印:
Proxy {i: 0, A: {…}, P: false, I: false, D: {…}, …}
[[Handler]]: null
[[Target]]: null
[[IsRevoked]]: true
所以.. 我真的不知道如何draftState.current.entries
使用 immer 对数组进行排序。
欢迎任何建议,
谢谢