Shopping Cart
Medium · Reducers
Make the cart work. Goal: practise useReducer.
Each product row has a "-" button, the quantity in <span className="qty"> and a "+" button. Quantities start at 0 and can never go below 0.
Below the list, <p className="total"> shows the total price, e.g. "Total: $8".
Tip: use actions like { type: "add", id } and { type: "remove", id }.
Next: Custom Hook: useToggle