React Developer Interview Question

Several screens need the same server data and it keeps getting refetched. How would you handle that?

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

Quick answer

Put the data in a caching layer keyed by request rather than in component state. A query library deduplicates concurrent requests for the same key, serves cached data instantly while revalidating in the background, and gives you one place to invalidate after a mutation. On the server side, request level caching plus prefetching in the route means the client often has the data before the component mounts.

Why interviewers ask this

The interviewer is testing whether you distinguish server state from UI state, which is the single biggest architectural decision in most React apps. They want to hear about cache keys, staleness and invalidation rather than a global store stuffed with API responses. Mentioning prefetching and request deduplication shows you have dealt with the waterfall problem in a real app rather than in a tutorial.

How to structure your answer

  • Name the category error: server data is a cache, not state.
  • Explain deduplication, stale time and background revalidation.
  • Cover invalidation after mutations and who owns the keys.
  • Add prefetching or server side fetching to kill the waterfall.

Example answer

Spoken example, first person

The root cause is usually that the data is being treated as component state, so every screen owns its own copy and its own fetch. I move it into a query cache keyed by something meaningful, like the resource name plus the id. Once it is keyed, three components asking for the same thing during one render pass produce one network request, and the second screen gets an instant paint from cache while a revalidation happens quietly behind it. I set stale time per resource rather than globally, because a user profile can be stale for minutes and a live order status cannot. Mutations then invalidate specific keys instead of everything, and I keep the key builders in one module so nobody invents a slightly different key and quietly breaks the cache. If the framework supports it I prefetch in the route or fetch on the server, so the data is already in flight before the component mounts, which is what actually removes the waterfall rather than just hiding it behind a spinner.

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 the stale time for a given resource?
  • How would you handle a mutation that affects several cached lists?
  • What is your approach when two screens need different shapes of the same data?

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