Skip to content
RED SAGSkills
mediumFrontend Developer interview question

How do you decide where to keep state in a React app: local state, context, a store, or a server-cache library?

What the interviewer wants to hear

  • Keep state local by default and lift only when needed
  • Separate server state from client UI state
  • Use a server-cache library like TanStack Query for API data
  • Context for rarely-changing global values like theme or user
  • A store like Zustand or Redux for complex shared client state
  • URL for state that should be shareable, like filters

Model answer

I start with local state and only move it higher when another component truly needs it. Then I separate two kinds of state. Server state is data from APIs: it needs caching, refetching, loading and error states, so I use TanStack Query or the framework data layer instead of putting it in a global store. Client UI state, like a modal being open, usually stays local. For values that many components read but that rarely change, like theme, locale or the logged-in user, React context works well. If there is complex client state shared across many screens, such as a multi-step editor, I use a small store like Zustand or Redux Toolkit, which also avoids context re-render issues. Filters and pagination often belong in the URL so users can share and refresh them.

Can you answer it under time pressure?

Take a timed medium round and get scored on every answer.

Start mock interview

More medium Frontend Developer questions