Cuando agrego el producto al carrito y luego agrego otro, entonces si intento agregar el primero nuevamente, no aumenta solo la cantidad sino que crea un nuevo objeto para este producto; Cómo puedo arreglarlo
switch (action.type) { case actionTypes.ADD_TO_CART: const product = state.products.find((p) => p.id === action.payload.id); const inCart = state.cart.find((item) => item?.product.id === action.payload.id ? true : false ); if (inCart) { let check = false; state.cart.map((item, key) => { if ( item.product.id === action.payload.id && item.setVar === action.payload.setVar ) { state.cart[key].quantity++; check = true; } }); if (!check) { const newItem = { product: product, setVar: action.payload.setVar, quantity: 1, }; state.cart.push(newItem); } } else { const newItem = { product: product, setVar: action.payload.setVar, quantity: 1, }; state.cart.push(newItem); } return { ...state, }; }item.product.id === action.payload.id && JSON.stringify(item.setVar) === JSON.stringify(action.payload.setVar)