Sometimes when i try to add 2 element to cart i have this problem, but if i refresh and try to make same things, this error doesn`t appear :
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading '_id')
context\StateContext.js (17:61) @ eval
15 |
16 | const onAdd= (product, quantity) => {
> 17 | const checkProductInCart = cartItems.find((item) => item._id === product._id );
| ^
18 |
19 | setTotalPrice((prevTotalPrice) => prevTotalPrice + product.price * quantity );
20 | setTotalQuantities((prevTotalQuantities) => prevTotalQuantities + quantity );.