State management: React Context patterns, kinds of state and where it lives (Redux, Zustand, context) – Front End interview prep

777 interview-style multiple-choice questions on State management (Redux, Zustand, context), organized by topic: concepts, scenarios, code to read and tradeoffs, each with a short explanation. Learn the 54 key terms with the flashcards first, then test yourself.

Take the practice test · Flashcards · All study tools

What it covers

  1. 7.1 Kinds of state and where it lives
  2. 7.2 React Context patterns
  3. 7.3 Redux fundamentals
  4. 7.4 Redux Toolkit and RTK Query
  5. 7.5 Zustand, Jotai and lightweight stores
  6. 7.6 Signals and fine-grained reactivity
  7. 7.7 Server state with TanStack Query and SWR
  8. 7.8 URL, form and persisted state
  9. 7.9 Choosing and scaling a state architecture

Key terms

7.1 Kinds of state and where it lives

Client state
Data owned by the UI, such as form inputs, toggles and preferences
Derived state
Values computed from other state instead of being stored
Ephemeral state
Short-lived client state that does not need to survive a reload, such as hover or open flags
Global state
State readable from many distant parts of the client; useful when shared, costly when overused
Impossible state
A state combination that should never occur
Local state
State owned by one component or a narrow parent, rather than by a global store or the server
Normalized state
Entities stored once by ID and referenced elsewhere
Server state
Data owned by the backend that must be fetched, cached and kept fresh
State machine
Model with explicit states and allowed transitions
State shape
How state is arranged so updates stay simple and facts are not stored in several places
Store
An object that holds state and notifies subscribers when it changes
UI state
Short-lived client state like open menus or focus
Unidirectional data flow
Views read state downward and request changes by sending events or actions upward

7.2 React Context patterns

Context
React's mechanism for passing a value through the tree without props
Context selector
Reading only part of shared state to limit re-renders
Prop drilling
Passing props through many layers that don't use them
Provider
The component that supplies a context value to its subtree
Provider hell
Deeply nested providers at the app root
useContext
Hook that reads the nearest matching context provider above a component
Default context value
The value createContext supplies when no matching provider is above the consumer
Value identity
Whether a provider's value is Object.is-equal to the previous one; a new object re-renders every consumer
use()
React 19 API that can read a context or Promise and may be called conditionally during render
Context splitting
Providing separately updating values through different context objects so they have different subscribers
displayName
A label you set on a context object so DevTools can name the provider and its consumers

7.3 Redux fundamentals

Action
A plain object describing what happened, with a type field
Immer
Library that lets you write mutating code on a draft and produces immutable updates
Memoized selector
Selector that recomputes only when inputs change
Middleware
Code between dispatch and the reducer
Reducer
A pure function (state, action) => newState
Selector
A function that reads (and can derive) a value from the store
Thunk
Function dispatched to run async logic

7.4 Redux Toolkit and RTK Query

createAsyncThunk
RTK helper that dispatches pending, fulfilled and rejected
Entity adapter
RTK helper for normalized collections
Redux Toolkit
Official, batteries-included way to write Redux
RTK Query
RTK's data fetching and caching layer

7.5 Zustand, Jotai and lightweight stores

Jotai
Atomic state library built from small atoms
Signal
A reactive value that updates only its dependents when it changes
TanStack Query
Library for fetching, caching and synchronizing server state
Valtio
Proxy-based state you can mutate directly
XState
State machine and actor library
Zustand
A small hook-based store with selector subscriptions and no provider

7.6 Signals and fine-grained reactivity

Computed
Derived reactive value that's cached
Fine-grained reactivity
Updating only the DOM parts that depend on a change
Glitch
Observers seeing inconsistent intermediate values

7.7 Server state with TanStack Query and SWR

gcTime
How long inactive data stays cached
Invalidation
Marking cached data stale so it refetches
Query key
Array identifying cached data in TanStack Query
staleTime
How long data is considered fresh

7.8 URL, form and persisted state

Dirty field
Form field changed from its initial value
Partial persistence
Saving only chosen fields of a store
URL state
State kept in the path or query string

7.9 Choosing and scaling a state architecture

God store
One huge store every feature depends on
Offline-first
Writing locally first and syncing later
Outbox
Local queue of writes sent when back online

Sample practice questions

  1. Which kind of state is the best fit for a global store such as Redux or Zustand?

    1. Data fetched from the server that needs caching and refetching
    2. Client state many distant components share, like a cart
    3. The text of a single input that only its own component reads
    4. A value that can be computed from other state during render

    Answer: B. Client state many distant components share, like a cart Keep local UI state local, server data in a server-state cache, and derived values computed rather than stored.

  2. What happens when a context provider's `value` changes?

    1. Nothing changes on screen until the page is reloaded
    2. Only components reading the specific changed field re-render
    3. Every component reading that context re-renders
    4. Only the provider re-renders, not its consumers

    Answer: C. Every component reading that context re-renders Context has no selector; large contexts can cause many unnecessary renders.

  3. In Redux, what is a reducer?

    1. A function that sends actions to the server and waits for a reply
    2. A middleware that logs every action to the console
    3. A pure `(state, action) => newState` function that doesn't mutate
    4. A component that subscribes to the store and re-renders

    Answer: C. A pure `(state, action) => newState` function that doesn't mutate Pure reducers make state changes predictable, testable and replayable in devtools.

  4. Why can Redux Toolkit's `createSlice` reducers write `state.items.push(x)`?

    1. RTK uses Immer, which turns draft "mutations" into new state
    2. The store is a mutable singleton anyway
    3. `push` is overridden to copy the array first
    4. Redux has allowed direct mutation since version 5

    Answer: A. RTK uses Immer, which turns draft "mutations" into new state You still get immutable updates; just don't both mutate the draft and return a new value.

  5. How does a Zustand store differ from a Context-based store?

    1. No provider; components re-render only when their selected slice changes
    2. Zustand stores need a provider at the root, just like Context does
    3. Zustand can only hold primitive values like strings and numbers
    4. Every component re-renders whenever any part of the store changes

    Answer: A. No provider; components re-render only when their selected slice changes `const count = useStore(s => s.count)` re-renders only when `count` changes.

  6. What is a "signal" in libraries like Preact Signals, Solid or Angular?

    1. A WebSocket message pushed from the server
    2. A reactive value that updates only the code that reads it
    3. A browser event fired on every state change
    4. A Redux action that carries a timestamp

    Answer: B. A reactive value that updates only the code that reads it Fine-grained reactivity can update the exact DOM node instead of re-rendering a component.

  7. Why is server-state caching (TanStack Query, SWR, RTK Query) often a bigger win than a global store?

    1. They remove the need for a backend API altogether
    2. Most "global state" is fetched data, which they cache and refresh
    3. They write data to the database directly from the browser
    4. They make API calls synchronous, so no loading states are needed

    Answer: B. Most "global state" is fetched data, which they cache and refresh After moving API data to a query cache, the remaining client state is often small.

  8. What belongs in the URL rather than in a store?

    1. The whole Redux store, serialized as JSON for safekeeping
    2. Access tokens and other secrets, so they survive reloads
    3. State users share, bookmark or restore with Back, like filters
    4. Every keystroke in a form, so drafts are never lost

    Answer: C. State users share, bookmark or restore with Back, like filters URL state survives reloads and links; never put secrets in it.

  9. What is the main argument against putting everything in Redux?

    1. Boilerplate for state that's local, derived or server cache
    2. Redux forces the app to use server-side rendering
    3. Redux doesn't work with TypeScript projects
    4. Redux can't hold more than 1 MB of state

    Answer: A. Boilerplate for state that's local, derived or server cache Use Redux for shared, complex client state where its structure and tooling pay off.

  10. What is "server state" and why is it different from client state?

    1. Backend-owned data that can change, so it needs caching and refetching
    2. Any state stored in a cookie, sent with every request automatically
    3. State that only exists while the page is rendered on the server
    4. State kept in a Redux store that runs inside the server process

    Answer: A. Backend-owned data that can change, so it needs caching and refetching Libraries like TanStack Query or SWR handle loading, caching, deduping and background refresh for it.

Practice all 777 questions

More Front End