我很想知道这两种改变状态的方式( comments 和非 comments )有什么不同?当调度不正常时,第一个问题会导致问题.为什么会这样呢?
export const correctiveSlice = createSlice({
name: "corrective",
initialState: initialCorrectiveState,
reducers: {
correctContent: (state, action: PayloadAction<CorrectiveState>) => {
// state = {
// item: {
// id: action.payload.item.id,
// text: action.payload.item.text,
// },
// edit: action.payload.edit,
// };
state.item = action.payload.item;
state.edit = action.payload.edit;
},
},
});
我使用的是传统的待办事项列表应用程序,但我使用的是Redux-Toolkit/Reaction-Redux库,而不是上下文API.当我try 使用第一种方法来改变状态时,它没有改变.