Took a bit of time poring over your code, not much was obviously wrong (other than state mutations), eventually I just cloned your repo into a codesandbox and debugged.
Issue
The issue is the state update from updateCount and another from removeFromCart. The condition this.findItem(cartItems, id).count == 1 && increment < 0 is true and this.removeFromCart is called, the cart item is found and a state update it enqueued. Execution returns to updateCount and a second state update is enqueued. The second update overwrites the first with the cartItems (state) enclosed in function scope.
updateCount = (id, increment) => { const cartItems = this.state.cart; if (this.findItem(cartItems, id).count == 1 && increment < 0) this.removeFromCart(id); else { this.findItem(cartItems, id).count += increment; } this.setState({ cart: cartItems // <-- State update #2 }); }; removeFromCart = (id) => { const cartItems = this.state.cart.filter((el) => el.id !== id); this.setState({ cart: cartItems // <-- State update #1 }); };
Solution
When removing an item from the cart only enqueue a single state update. Tuck the second update into the logic branch that is updating it.
updateCount = (id, increment) => { const cartItems = this.state.cart; if (this.findItem(cartItems, id).count == 1 && increment < 0) this.removeFromCart(id); else { this.findItem(cartItems, id).count += increment; this.setState({ cart: cartItems }); } };
At this point your code appears to function correctly, but I should note that this.findItem(cartItems, id).count += increment; is technically a state mutation. It's obscured by the fact that a line later you at least copy into a new state object. You should always avoid state mutations. I suggest the following edit to map to a new cart array when updating item counts. Also use === instead of == for equality comparisons unless you have a good reason to.
updateCount = (id, increment) => { const cartItems = this.state.cart; if (this.findItem(cartItems, id).count === 1 && increment < 0) this.removeFromCart(id); else { this.setState({ cart: cartItems.map((item) => item.id === id ? { ...item, count: item.count + increment } : item ) }); } };

findItemdo? Looks like you is mutating some object.removeFromCart.findItemhelps to get the object whose id is equal toid.