我的减速机如下:
export const favorites = (state = {
favorites: [],
countFavorite: [],
}, action) => {
switch (action.type) {
case ActionTypes.ADD_FAVORITE:
return { ...state, favorites: action.payload };
case ActionTypes.COUNT_FAVORITE:
return { ...state, countFavorite: [...state.countFavorite, action.payload] };
default:
return state;
}
};
电流我得到以下与旧状态和新状态:
我希望新对象用数组中的相同键覆盖现有对象,非常感谢任何帮助