Lists and formsPath 12/21
ListsFormsState & eventsDerived state
Prerequisites are suggestions only. Every challenge stays open.
Shopping Cart
Build a cart whose UI is derived from one source of truth: the items array.
Requirements
- Render cart items from state using stable keys.
- Increment and decrement quantities without mutating existing objects or arrays.
- Prevent quantities from falling below one.
- Remove an item by its
id.
- Derive the item count, line totals, and subtotal; do not store them as separate state.
- Render an empty state when the last item is removed.
Stretch goal
Add a promo-code input that applies a 10% discount for the code REACT10.