Frontend Developer interview question

How do you choose a state-management approach?

Keep state as local as possible and derive values instead of duplicating them. Move state upward only for real sharing, use server-state tools for remote data, and choose a global store when cross-tree coordination is stable and justified.

Direct answer

What a strong answer covers

How it works

State has different owners: UI state belongs to the component that renders it, form state to the form, server data to a cache keyed by the request, and truly global concerns such as the current user or theme to a context or store. Each promotion to a wider scope costs coupling and re-render surface, so the default is the narrowest owner that works. Deriving values during render instead of storing them removes a whole class of stale-state bugs.

Example

A modal open flag belongs near the feature; authenticated user data belongs in a server-data cache with invalidation rules. A shopping cart that must survive navigation and sync across tabs justifies a small store with explicit actions, whereas the search box text does not.

Common mistakes

  • Putting every piece of state in one global store because it is convenient.
  • Copying server data into local state and then fighting to keep the two in sync.
  • Storing derived values such as a filtered list instead of computing them from the source.

A useful answer structure

Answer from your own work.

Do not memorise a script: use only examples you can explain honestly in follow-up questions.

Practise this answer with MiraHint

Open the desktop workspace and rehearse a clear answer in your own words.

Download MiraHint
Frontend Developer interview questions