Это происходит потому, что вы изменяете хранилище избыточности. В вашем коде:
case CartActionTypes.ADD: {
let itemExists = state.cart.find(cart => cart.productId === action.product.productId);
if (itemExists) {
itemExists.count = itemExists.count + 1;
return {
...state,
...state.cart
};
} else {
let cart: ICart = { productId: action.productId, product: action.product, count: 1 };
state.cart.push(cart);
return {
...state,
...state.cart
};
}
}
Переключитесь на
case CartActionTypes.ADD: {
let itemExists = state.cart.find(cart => cart.productId === action.product.productId);
if (itemExists) {
itemExists.count = itemExists.count + 1;
return {
...state,
cart: [...state.cart, itemExists]
};
} else {
let cart: ICart = { productId: action.productId, product: action.product, count: 1 };
return {
...state,
cart: [...state.cart, cart]
};
}
}