State management
Redux, Zustand, context and server state, and when to use which.
21 lessons 51 practice questions about 2 hours of reading
Chapter 1, beginner
Foundations
What it is and how it works, the questions every round starts with.
- 01Server state vs client state in React: what is the difference?
Lesson, 6 min read, then 6 questions to practise
- Design the state architecture of a large app: server cache, URL, global and local state
- Build a mini React Query: QueryClient, useQuery, prefix invalidation and garbage collection
- Implement useQuery() with caching, retries, and stale data
- Build a data browser over a remote API: a shared cache, deduplicated requests, prefetch and no stale data
- Load a list, then the selected item's details, without races: abort, ignore stale responses and cache by id
- Stop a context from re-rendering every consumer
- 02What is Redux, and how does it work?
Lesson, 6 min read, then 6 questions to practise
- Implement a small Redux-style store using subscriptions and reducers
- Implement Redux createStore() with enhancers and applyMiddleware(): middleware order, thunk and logger
- Build createSlice() and createAsyncThunk() from scratch, wired to a store and React
- Type a reducer and its actions with a discriminated union
- Normalize nested API data into entities with memoized selectors
- Design an ops dashboard for food orders not accepted within 2 minutes: detection pipeline, Redux store and live push
Chapter 2, intermediate
In depth
How it behaves under the hood, and the follow-ups that come next.
- 04Context API vs Redux: which should you use?
Lesson, 5 min read, then 3 questions to practise
- 05How do optimistic updates work with TanStack Query?
Lesson, 6 min read, then 6 questions to practise
- Implement optimistic UI updates with rollback on failure
- Build an async settings switch with optimistic updates, rollback and out-of-order responses
- Build useOptimistic from scratch: queued optimistic updates, rebase on server results and rollback
- Change an existing username: cached availability checks, an optimistic save and rollback on conflict
- Build a nested drag-and-drop tree editor with optimistic reordering
- Design LinkedIn feed reactions and comments: optimistic updates, counters at scale, ordering and live updates
- 06How do you normalize state in Redux, and why does it matter?
Lesson, 5 min read, then 4 questions to practise
- Implement Redux Toolkit's createEntityAdapter(): CRUD updates, upserts, sorted ids and selectors
- Fix useSelector re-renders on every dispatch: createSelector, shallowEqual and selector factories
- Implement Reselect's lruMemoize and createSelectorCreator(): cache size, result equality and recomputations
- Write a todos reducer with immutable updates: add, toggle, edit, remove, reorder and clear completed
- 07How does createSlice work in Redux Toolkit?
Lesson, 5 min read, then 3 questions to practise
- 08How does Zustand work?
Lesson, 6 min read, then 4 questions to practise
- 09Redux thunk vs redux-saga: what is the difference?
Lesson, 6 min read, then 4 questions to practise
- 10RTK Query providesTags and invalidatesTags: how do they work?
Lesson, 8 min read, then 2 questions to practise
- 11RTK Query vs TanStack Query (React Query): which should you use?
Lesson, 5 min read, then 2 questions to practise
- 13TanStack Query vs Redux for data fetching: which should you use?
Lesson, 5 min read
- 14TanStack Query vs SWR: which should you use?
Lesson, 8 min read
- 15useSelector vs connect in React-Redux: what is the difference?
Lesson, 5 min read, then 1 question to practise
- 16What is createAsyncThunk in Redux Toolkit, and how does it work?
Lesson, 5 min read, then 3 questions to practise
- Add condition, getPendingMeta and serializeError to createAsyncThunk(): skip duplicate fetches and serialise errors
- Write Redux middleware that turns callAPI actions into request, success and failure actions
- Write optimistic Redux thunks that roll back only their own change when one of several concurrent saves fails
- 18What is Redux middleware, and how does it work?
Lesson, 5 min read
- 19What is Redux Toolkit, and why should you use it?
Lesson, 6 min read
- 20What is RTK Query, and how does it work?
Lesson, 5 min read
- 21Zustand vs Redux: which should you use?
Lesson, 6 min read