React Query Under the Hood
summary
Builds a tiny React Query clone in vanilla JS and React hooks, wiring a createQuery/client that holds a global map of query instances so references survive navigations. Implements caching, a pub-sub for subscriber updates, deduping via request state to avoid duplicate network calls, and time-based policies: staleTime 10s, gcTime 15s. Live demo fetches posts, shows free background refetch when cache exists, and the implementation works as presented.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 5:18Abstracting React Query
- 10:12Connecting to React
- 12:23Query instance management
- 16:38Styling and revalidate
- 18:45Garbage collection time
- 22:43Summary and basic implementation
- 23:48React 18 External Store
- 24:50Q&A
related talks
41mReact Query: The Next Big Library?
27mLet's Build React Query in 150 Lines of Code!
11mSimple data fetching with React Query
20mReact Query API Design – Lessons Learned
30mReact Query API Design: Lessons Learned
29mReact Query: It’s Time to Break up with your "Global State"!
39mReact-query: A Lightweight and Convenient Caching Library for React Apps
21mData Fetching with React Query A Crash Course
