- React
- State Architecture, Store Subscriptions, and Server Cache
React State Management Interview Questions
React state management interview questions, common in senior frontend system design interviews, evaluate your ability to choose the right state management architecture for a given application complexity and scale.
Analyze the critical difference between client UI state and server cache. Learn why Context is not a state management tool, explore fine-grained selector subscriptions in Zustand, inspect Redux Toolkit normalized state, and master TanStack Query caching mechanics.
React State Management Interview Questions: 5 lessons
State Taxonomy: Local vs Global & Server State
There are five types of state in React: local UI state (useState), shared client state (Zustand/Context), server cache state (TanStack Query), URL state (searchParams), and persistent device state (localStorage). Choosing the wrong bucket causes synchronization bugs and unnecessary re-renders.
Context API in React: Splitting & Selectors
The Context API in React re-renders every consumer when its value changes, so split contexts and use selector patterns to stop it. At scale, mitigate this by splitting state and dispatch into separate contexts, colocating providers, or using external stores with fine-grained selectors.
Zustand: Store Architecture & Fine Subscriptions
Zustand is a lightweight, hook-based state management library built on an external store model. Components subscribe via fine-grained selectors that evaluate equality before triggering re-renders, completely eliminating Context provider nesting and unnecessary re-render cascades.
Redux Toolkit (RTK): Slices & Normalized State
Redux Toolkit is the recommended way to use Redux in React: it abstracts boilerplate with createSlice, integrates Immer for safe mutable-style draft updates, and providing createEntityAdapter to maintain normalized O(1) relational state by ID, avoiding nested array manipulation.
Server State vs Client State: TanStack Query
Server State vs Client State: TanStack Query manages server state as an asynchronous remote cache governed by stale-while-revalidate semantics. It eliminates client-side data fetching boilerplate by automating background refetching, request deduplication, cache garbage collection, and optimistic UI updates.
