Hydra
Bug library · state · state

Stale quote after a quantity change

The price quote is memoised on the number of cart lines instead of the lines themselves, so + and - change nothing on screen until an item is added or removed or a coupon is applied.

Breaks: main, holdout · expected from Kane: caught · Correct after every add/remove and on coupon apply; wrong only right after a quantity click. The main spec checks the quantity immediately after clicking +, so Kane has to click through the change to see it.

The diff

components/Checkout.tsx
- const quote = useMemo(() => computeQuote(lines, coupon), [lines, coupon]);
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- only recompute when the cart grows or shrinks
+ const quote = useMemo(() => computeQuote(lines, coupon), [lines.length, coupon]);

Matches

No recorded match has planted this bug yet.