Skip to main content

State management system design interview questions

This chapter tests whether you can classify state before choosing a library.

A strong default model is:

state
↓
who owns the truth?
↓
what is its lifetime?
↓
who subscribes?
↓
how often does it change?
↓
what failure/security rules apply?
↓
choose the smallest appropriate tool

Classification​

1. What categories of state do you distinguish in a React application?​

Strong answer: Local UI state, shared React-owned state, external client state, server state, form state, URL/navigation state, and sometimes durable browser state. The categories overlap in use cases but differ in source of truth and lifecycle.

2. Why start with ownership instead of library choice?​

Strong answer: Libraries are mechanisms. Ownership determines consistency rules, lifetime, subscriptions, persistence, and failure handling. Wrong ownership creates duplicate truth even if the library API is technically correct.

3. What is a source of truth?​

Strong answer: The authoritative representation that other views derive from. If two independently mutable representations both claim authority, synchronization bugs become likely.

4. Is β€œglobal state” a useful enough classification?​

Strong answer: Not by itself. It says many consumers need access, but not whether the state is server-owned, form-owned, URL-owned, session-scoped, persistent, or high-frequency.

5. What questions do you ask before adding a store?​

Strong answer: Who owns this state? Which consumers need it? How long should it live? Does it survive navigation/reload? How frequently does it update? Does it need server synchronization? Can it be derived? Does it contain sensitive data?

Local state vs shared state​

6. When should state remain local?​

Strong answer: When one component/subtree owns it and external consumers do not need coordinated access. Local ownership keeps dependencies explicit and update scope small.

7. When should state be lifted?​

Strong answer: When sibling consumers need the same React-owned value and their nearest common owner can reasonably coordinate it.

8. When does lifting become a smell?​

Strong answer: When state is threaded through unrelated layers, ownership becomes unclear, update frequency creates broad render pressure, or the shared lifetime no longer matches the component tree.

Context​

9. What is Context best at?​

Strong answer: Distributing a value through a React subtree, especially dependencies/configuration or shared state whose scope aligns with the tree.

10. What is Context not?​

Strong answer: It is not automatically a state store, reducer, server cache, or fine-grained subscription system. It distributes whatever value the provider supplies.

11. When does Context performance become a concern?​

Strong answer: When a provider value changes frequently and many consumers subscribe to the same broad value. Split ownership/contexts or use an external subscription model when needed.

12. Context vs Redux Toolkit?​

Strong answer: Context is tree-scoped distribution. Redux Toolkit provides an external store, explicit events/reducers, selectors, middleware, DevTools, and stronger conventions for coordinated application state.

13. Context vs Zustand?​

Strong answer: Context scopes access through the tree; Zustand owns state externally and supports selector-based subscriptions. They can also combine: Context can provide a scoped store instance.

Redux Toolkit vs Zustand​

14. When would you choose Redux Toolkit over Zustand?​

Strong answer: When event traceability, reducer conventions, middleware, standardized async patterns, Redux DevTools workflows, large-team governance, or RTK Query integration materially help.

15. When would you choose Zustand over Redux Toolkit?​

Strong answer: When the state problem is simpler and a lightweight external store with direct actions/selectors provides enough structure without needing Redux’s event/middleware model.

16. Is fewer lines of code a sufficient architecture argument for Zustand?​

Strong answer: No. Compare operational complexity, team ownership, debugging, state transitions, testability, migration, and ecosystem requirements.

17. Can Redux Toolkit be simpler than Zustand for a large organization?​

Strong answer: Yes. A more explicit framework can reduce organizational ambiguity even if the API surface is larger.

Server state​

18. Why should server data usually stay out of ordinary client stores?​

Strong answer: Server data has remote authority plus freshness, retries, invalidation, cache lifetime, mutation reconciliation, and request lifecycle concerns that purpose-built server-state tools already solve.

19. When is copying Query data into Zustand/Redux justified?​

Strong answer: When it intentionally becomes separate client-owned state, such as an editable draft, workflow snapshot, offline model, or transformed local entity with a different lifecycle. Document that ownership transfer explicitly.

20. What is the danger of mirroring query cache into a store?​

Strong answer: Two mutable copies drift. Every refetch/mutation/update requires synchronization logic and race handling.

21. TanStack Query vs RTK Query?​

Strong answer: Both are server-state solutions. RTK Query integrates into Redux Toolkit and is compelling when Redux is already a core architecture. TanStack Query is independent and focused on server state. Choose based on architecture and team constraints.

22. Can TanStack Query and Redux Toolkit coexist?​

Strong answer: Yes. Redux can own client state while Query owns server state. Keep ownership boundaries explicit.

Form state​

23. Why should form state usually not live in Redux/Zustand?​

Strong answer: Form drafts have a specific local lifecycle, validation metadata, field subscriptions, and submission behavior. A form library or local state usually owns that better.

24. When should a form value be promoted to application state?​

Strong answer: When it must outlive the form lifecycle or coordinate other features before submission, and that ownership is intentional rather than incidental.

25. Query data β†’ RHF form: where does ownership change?​

Strong answer: Query owns the authoritative fetched snapshot; the form owns the in-progress editable draft after initialization. Submission reconciles back to the server, then query cache updates/refetches.

26. Why not reset the form on every query refetch?​

Strong answer: It can overwrite unsaved user edits. Define conflict and refresh behavior instead of assuming remote data continuously owns the draft.

URL state​

27. What belongs in the URL?​

Strong answer: State that should be shareable, bookmarkable, navigable, or preserved by browser history: filters, search query, pagination, selected resource/tab when navigation semantics matter.

28. Why is duplicating URL filters into a store risky?​

Strong answer: Back/forward navigation and direct links can diverge from store state. Prefer deriving from the URL unless there is a clear separate draft model.

29. URL vs Zustand for selected dashboard filters?​

Strong answer: If users should share/reload/back through the filter state, URL is the better authority. Zustand can own ephemeral UI preferences that are not navigation state.

Persistence​

30. What state should survive reload?​

Strong answer: Only state with a defined durable lifecycle: user preferences, drafts when intentionally recoverable, or client data designed for offline use. Persistence should not be the default for every global state value.

31. Why is persisted state a schema?​

Strong answer: It survives software versions, so field changes require versioning/migrations just like other durable data formats.

32. What security questions apply to browser persistence?​

Strong answer: Sensitivity, XSS exposure, shared-device behavior, tenancy/user switching, expiry, logout cleanup, and whether the data should exist on the client at all.

SSR and request isolation​

33. What is the central external-store SSR risk?​

Strong answer: Server-global mutable state can leak data between requests/users.

34. How do you prevent request leakage?​

Strong answer: Scope request-specific stores/caches per request and serialize only safe initial state needed by the client.

35. What causes hydration mismatch in stateful apps?​

Strong answer: The client’s initial render differs from server output due to persisted browser state, time/randomness, environment-only values, or different initial store snapshots.

36. Does putting state in Context fix request isolation?​

Strong answer: Only if the provider/store instance itself is request-scoped. Context distribution does not magically change the lifetime of a global singleton.

Performance​

37. What is the most important performance question for state architecture?​

Strong answer: Which updates cause which consumers to render or recompute? Subscription/update scope matters more than the brand of state library.

Strong answer: Measure with React DevTools/Profiler and library tooling, identify the update source, inspect provider/store selectors, and narrow ownership/subscriptions before adding memoization.

39. Would you choose Zustand solely because Context re-renders too much?​

Strong answer: First confirm the problem. Provider value design, context splitting, state placement, and component boundaries may solve it. Use an external store when selector subscriptions/ownership genuinely fit.

40. High-frequency pointer coordinates: Context, Redux, Zustand, or ref/external source?​

Strong answer: Often a ref/external subscription or carefully scoped store depending on whether rendering needs every update. Do not broadcast 60–120 updates/sec through a broad Context tree without measurement.

Security​

41. Does client state prove authorization?​

Strong answer: No. Client state can guide UI but the server must enforce authorization.

42. Should permissions be cached client-side?​

Strong answer: They can be cached for UX, but sensitive operations still require server authorization. Cache invalidation and session/tenant changes must be considered.

43. What state-management bug can become a tenant data leak?​

Strong answer: A shared cache/store key that omits tenant/user identity, a server-global store reused across requests, or persisted state not cleared/scoped on account changes.

Migration​

44. How do you migrate Context state to Redux/Zustand safely?​

Strong answer: Establish the new owner, adapt existing consumers through a temporary boundary, migrate writes/reads incrementally, then delete the old source. Avoid a long-lived two-way sync layer.

45. How do you migrate manual useEffect API fetching to TanStack Query?​

Strong answer: Define stable query keys/functions, replace component request lifecycle state with query ownership, migrate mutation invalidation/update rules, remove old Effects/cache copies, and add tests for freshness/error/loading behavior.

46. How do you migrate global form state into RHF?​

Strong answer: Create a dedicated form model/defaults, migrate fields/validation/submission, keep only genuinely application-owned values outside the form, then remove duplicate global draft state.

47. What is the strangler pattern for state migration?​

Strong answer: Route one feature/slice at a time through the new owner behind adapters, reducing blast radius while preventing new code from expanding the legacy model.

48. How do you know migration is complete?​

Strong answer: One authoritative owner remains, compatibility adapters are removed, old subscriptions/writes are gone, metrics/tests are stable, and operational docs reflect the new model.

Senior system-design prompts​

49. Design state for an ecommerce product page.​

Strong answer: URL owns product ID/options that should be shareable; Query owns product/inventory/server data; local state owns transient gallery/UI; RHF or local form state owns configurable inputs; cart mutation updates server cache; authentication UI state does not replace server authorization.

50. Design state for a trading dashboard.​

Strong answer: Server cache/query or streaming infrastructure owns market/server data; local/store state owns workspace layout and UI preferences; URL owns shareable symbol/timeframe; high-frequency data uses subscription architecture designed for update rate; forms own order drafts; server enforces trade authorization.

51. Design state for a multi-tenant SaaS admin app.​

Strong answer: Tenant identity is part of cache/request scope; URL may own selected tenant/resource; server state cache owns remote entities; shared client store owns cross-route UI/session preferences; forms own drafts; permissions are validated server-side; caches/stores reset or scope on tenant/account changes.

52. Design state for a collaborative editor.​

Strong answer: Separate durable remote document state, real-time collaboration presence, local unsaved interaction state, selection/cursor state, preferences, and URL document identity. Do not force all of these into one generic store with one update model.

53. A team wants one universal state library. How do you respond?​

Strong answer: Standardize decision rules and integration patterns rather than forcing unrelated ownership models into one mechanism. Consistency is valuable, but conceptual correctness and failure semantics matter more than a single dependency.

54. What would a state-ownership ADR contain?​

Strong answer: State category, source of truth, scope/lifetime, persistence, subscriptions, server synchronization, security boundaries, failure behavior, chosen tool, alternatives, migration plan, observability, and review triggers.

55. What state-management metrics would you monitor?​

Strong answer: Render/update cost, request/refetch volume, cache hit/freshness behavior, mutation failure/retry rates, hydration errors, persistence/migration errors, memory footprint for large caches, and user-facing latency.

Decision drill​

For each value choose a likely owner and justify it:

ValueLikely owner
modal openlocal state
theme shared by appContext or client store
complex cross-feature workflowRedux Toolkit/Zustand depending constraints
products from APITanStack Query or RTK Query
checkout draftReact Hook Form
page/filter/searchURL when shareable/navigation state
DOM measurementref/state depending whether render must react
server permissionsserver authority; client may cache for UX

The table is not a law. The interview skill is explaining why ownership matches requirements.

Rapid-fire checks​

  1. One library must own all state? No.
  2. Server data copied into a store by default? No.
  3. Form values globally stored by default? No.
  4. URL can be a state store? Yes.
  5. Persistence is architecture? Yes, because it changes lifetime/security.
  6. Client permissions authorize requests? No.
  7. Context can provide a Zustand store instance? Yes.
  8. Redux and Query can coexist? Yes.
  9. Store size alone determines performance? No.
  10. The best tool is chosen after classifying ownership? Yes.