React Developer Interview Question

How do you decide where a given piece of state should live?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Start as local as possible, inside the component that uses it, and lift it only to the closest common ancestor when siblings genuinely need to share it. If it is server data, it belongs in a caching data layer, not component state. If a user should be able to link to it, such as filters or the current tab, put it in the URL. A global store is the last resort.

Why interviewers ask this

This question reveals architectural instincts more than any framework trivia. The interviewer wants to see that you classify state by kind, server data versus UI state versus URL state, rather than defaulting everything into a global store. They are also watching for awareness of the costs of premature lifting, since state pushed too high causes wide re-renders and prop drilling that are painful to unwind later.

How to structure your answer

  • Classify the state first: server, URL, local UI, or truly global.
  • State the default of keeping it as local as possible.
  • Give your trigger for lifting or moving it to a store.
  • Name the cost of getting it wrong in either direction.

Example answer

Spoken example, first person

My first move is to work out what kind of state it is, because most things people call state are not really local state. If it came from the server, it goes in a query cache, so I get deduplication, revalidation and staleness handling instead of hand rolling it into useState and an effect. If it should survive a refresh or be shareable as a link, like the active filters or which tab is open, it goes in the URL. Whatever is left is genuine UI state, and that starts in the component that uses it. I only lift when a second component actually needs it, and then only to the nearest common parent. Global stores I keep for things that are genuinely app wide, like the current user or a websocket connection. The failure I have cleaned up most often is state that got lifted to a top level provider because two components needed it once, and two years later everything re-renders on every keystroke and nobody dares move it back down.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How do you decide something belongs in the URL rather than in memory?
  • What breaks when server data is duplicated into component state?
  • How would you refactor state that was lifted too high?

Related react developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot