Avoiding Expensive Mishaps with Effective State Management
summary
A junior mistake leads to a $50,000 cloud bill after an un-cached product page repeatedly fires fetches on remount, causing excessive API calls under traffic. The fix shown is explicit: use React Query (TanStack Query) to cache and background-refetch, use Zustand for selective global caching outside Reactβs render cycle, add alerts and rate limiting, and follow a practical β321 ruleβ (where state lives, frequency, impact; cache + monitor; simplify). Example site is rebuilt and costs drop.
AI-written summary Β· about
chapters (14)
- 0:00Introduction and context
- 2:30Defining the problem
- 3:30Analyzing the mistake
- 6:03Technical root cause
- 7:25State management overview
- 8:42Impact of poor state
- 9:53Server state with React Query
- 11:30React Query implementation
- 12:27Global state with Zustand
- 13:13Zustand implementation
- 13:58Preventative measures
- 14:32The 3-2-1 rule
- 15:45Mental health and wrap-up
- 19:20Closing and connections








