Interview rehearsal

How to structure answers, system design prompts and traps.

Sixty-one chapters gave you the material: a toy React you built yourself, the real APIs mapped back to it, concurrency, the Compiler, every kind of state, Server Components, Next.js and production. This last chapter is about the part that happens in the room. A conceptual interview doesn't test whether you know React; it tests whether you can explain it, under time pressure, to someone deciding whether they'd trust your judgment on their codebase.

So here's a repeatable shape for answers, how to think aloud and handle the question you can't answer, the myths interviewers use as traps, five frontend system design prompts worked through end to end, and a checklist for the last hour before the call.

The problem: knowing it isn't the same as saying it#

Here's a real-sounding answer to "What does useEffect do?":

"So useEffect is for side effects, like, you know, fetching data and stuff, and it runs after render, and you have the dependency array, and if you leave it empty it runs once, and there's the cleanup function, which is for, like, cleaning up, and you should be careful because it can cause infinite loops."

Every clause is roughly true. The interviewer still learned almost nothing: no definition they could repeat, no mechanism, no sign you know when not to use it, and "runs once" is wrong in development under Strict Mode. Compare:

"An effect synchronizes a component with something outside React, like a subscription, a timer or a DOM API. React runs it after the commit, once the screen is updated, and before the next run or on unmount it runs your cleanup, so the setup and cleanup should mirror each other; that's why Strict Mode runs setup, cleanup, setup in development. The trade-off is an extra pass after every render where dependencies changed, so it's the wrong tool for anything you can compute during render or do in an event handler. For example, a chat room connection belongs in an effect keyed on the room id; a filtered list doesn't. In production I'd fetch with a data library or a framework loader rather than raw effects, and keep effects for true synchronization."

Same knowledge. The second one is organized, and organization is what's being graded.

A repeatable shape for answers#

Most conceptual questions fit five parts, in this order:

  1. Definition, one sentence. What it is, in words the interviewer could repeat.
  2. Mechanism. How it actually works. This is where the toy React from Part 2 pays off: you can say "a hook is a slot on the fiber, read in call order" instead of "hooks are magic, follow the rules".
  3. Trade-off. What it costs or when it's the wrong tool. Seniority shows here more than anywhere.
  4. Example. One concrete case, ideally from something you've built.
  5. What I'd do in production. Your default, and when you'd deviate. It turns knowledge into judgment.
The shape of a strong answer
Definitionone sentence~5 sMechanismhow it works~20 sTrade-offwhat it costs~15 sExamplea concrete case~15 sIn productionwhat I'd do~10 sAbout a minute. Then stop and let the interviewer pick the follow-up.
Step 1 of 6

The question: "What does a key do in React?" Five parts, about a minute in total. Each part answers the follow-up the interviewer would otherwise have to ask.

Aim for about a minute, then stop. Stopping is part of the technique: the interviewer has a follow-up planned, and a crisp answer gives them room to ask it. If you want to signal depth, offer it instead of delivering it: "I can go into how the reconciler matches keys if that's useful."

Not every question needs all five. "What's JSX?" needs a definition, a sentence of mechanism (jsx() calls returning plain objects) and maybe an example. "Context or a store?" is almost entirely trade-off. Use the shape as a checklist, not a script: before you stop talking, ask yourself whether you said how it works and when it's wrong.

Thinking aloud#

Interviewers can't grade reasoning they can't hear. Three habits:

  • State assumptions before answering. "I'll assume this is a client component on React 19 with createRoot." Half of React answers change with the version or the environment, and saying so shows you know that.
  • Trace code render by render. For "what does this log?" questions, don't guess the final output. Say: "Render 1: count is 0. Click: three setters queue 'replace with 1'. Render 2 applies them: 1." That's the state snapshot model made audible, and if you slip, the interviewer can see where.
  • Check in at forks. "This could be about server state or client state. Which do you mean?" One clarifying question is a strength; five in a row is stalling.

When you don't know#

You will hit a question you can't answer. What separates candidates is what happens next.

  1. Say so plainly. "I haven't used resumeAndPrerender directly." Bluffing is the one thing that reliably sinks an interview, because the follow-up exposes it and then everything else you said gets discounted.
  2. Reason from what you do know. "But I know React 19.2 added resume APIs for partial prerendering: you prerender a static shell, save the postponed state, and resume rendering the dynamic parts later. So I'd guess resumeAndPrerender finishes that into static HTML instead of a stream." First principles plus an honest label ("I'd guess") is a good answer.
  3. Say how you'd find out. "I'd check the react-dom/static docs and try it in a small script." That's what you'd do at work, and it's what they're hiring.

The same goes for things you half-remember. "I believe it's 19.1, but I'd double-check" is better than a confident wrong version number.

Quick checkThe question you can't answer

An interviewer asks how React's lanes model assigns priorities to updates, and you only know the general idea. What's the strongest response?

Traps and myths#

Interviewers often ask a question with a false premise built in, or wait to see whether you repeat a myth. These come up constantly. Each links to the chapter that teaches the real answer.

"The virtual DOM is faster than the DOM"#

It isn't. Hand-written, targeted DOM updates are always at least as fast, because the virtual DOM is extra work on top of the same DOM calls. The virtual DOM makes a declarative model fast enough: you describe the whole UI and React computes a small set of DOM operations. The win is correctness and productivity at acceptable cost. See The virtual DOM and diffing.

"Use an effect to keep derived state in sync"#

If a value can be computed from props or state, compute it during render. Storing it and syncing with useEffect costs an extra render, briefly shows stale values, and breaks the moment a dependency is missed. Expensive computations get useMemo (or the Compiler), not an effect. See Effects and Kinds of state.

Fix itThe list that ignores new books

This reading list keeps a filtered copy of books in state and syncs it in an effect. Filtering works. But click Add book and the new book never appears. Fix it so the list is always the current books filtered by the current query, and remove the state that shouldn't exist.

import { useEffect, useState } from "react";
import { books as allBooks } from "guide-tools";

type Book = (typeof allBooks)[number];

export default function App() {
  const [books, setBooks] = useState<Book[]>(allBooks.slice(0, 4));
  const [query, setQuery] = useState("");
  const [visible, setVisible] = useState<Book[]>(books);

  useEffect(() => {
    setVisible(books.filter((b) => b.title.toLowerCase().includes(query.toLowerCase())));
  }, [query]);

  function addBook() {
    setBooks((bs) => [...bs, { id: 100 + bs.length, title: "Thinking in React", author: "You", year: 2026, tags: [] }]);
  }

  return (
    <div>
      <label>
        Filter <input value={query} onChange={(e) => setQuery(e.target.value)} />
      </label>{" "}
      <button onClick={addBook}>Add book</button>
      <ul>
        {visible.map((b) => (
          <li key={b.id}>{b.title}</li>
        ))}
      </ul>
    </div>
  );
}

"Wrap everything in useMemo and useCallback"#

Memoization isn't free: it adds comparisons, memory and code, and a useCallback only helps when the function is passed to something that checks identity, like a memo child or an effect's dependencies. Structural fixes (move state down, pass slow parts as children) often beat it, and in 2026 the React Compiler does the rest automatically. The senior answer: measure first, fix structure, memoize where profiling says so, and turn the Compiler on. See Memoization and The React Compiler.

"Context is a state manager"#

Context is dependency injection: it passes a value down the tree. It doesn't manage anything, has no selectors, and every consumer re-renders when the value changes. Great for values that change rarely (theme, current user, a store instance); poor for frequently changing state read by many components, where a store with selectors (Zustand, Redux Toolkit, useSyncExternalStore) re-renders only the components whose slice changed. See Context and Build a store.

"Server Components replace client state"#

They replace a lot of client-side data fetching: data can be read on the server and streamed as rendered UI, so many useEffect fetches and some server-cache usage go away. They don't replace interactive state. Server Components can't use state or effects at all. A dropdown's open flag, a form draft, optimistic updates and anything that changes without a round trip still live in client components. See Server Components and Choosing state tools.

"Never use the index as a key" (and its opposite)#

Both absolutes are wrong. Index keys are fine for a static list that's never reordered, filtered or inserted into, and whose items hold no state. They break when items move, because state and DOM stick to positions. Random keys (Math.random()) are always wrong: everything remounts on every render. Use a stable id from the data. See Keys.

More you'll hear#

  • "setState is async." Not quite. It doesn't return a promise; it queues an update and React renders after your handler finishes, batched. Inside the handler you see the snapshot from the current render. See State.
  • "A re-render means the DOM changed." A render calls your components and diffs the result. The DOM is touched only where the output changed. Renders are often cheap; unnecessary expensive renders are the problem. See Rendering and scheduling.
  • "Strict Mode's double render is a bug." It's a development-only check that your renders are pure and your effects clean up. See Effects.
  • "SSR and Server Components are the same thing." SSR turns components into HTML for the first load. Server Components are components that only ever run on the server and send a serialized tree; they work with or without SSR. See SSR and hydration.
  • "The Compiler means I don't have to follow the rules." The opposite: it assumes the Rules of React and can change behavior when code breaks them. See The React Compiler.

Frontend system design#

Senior loops often include a frontend system design round: "design a typeahead", "design a news feed". There's no code, and no single right answer. You're graded on whether you cover the dimensions that matter, make trade-offs explicitly, and go deep where the problem is hard.

Walk through the same sequence every time:

  1. Requirements. Functional (what the user can do) and non-functional (devices, scale, latency targets, offline, SEO, accessibility). Ask two or three clarifying questions, then write down what you'll assume.
  2. Data and API. The entities, the endpoints or queries, pagination, and what's real-time.
  3. Component tree. Boxes from the data, named, three levels deep at most.
  4. State placement. For each piece of state: server cache, URL, local, form, shared client store, or derived. The Kinds of state chapter is this step.
  5. Data fetching and caching. Who fetches, when, how it's cached and invalidated.
  6. Rendering strategy. CSR, SSR, static, streaming, Server Components, and why. See Rendering strategies.
  7. Performance. Bundle size, render cost, network, Core Web Vitals.
  8. Accessibility. Semantics, keyboard, focus, announcements.
  9. Testing. What you'd test at which level.
  10. Failure modes. Slow network, errors, races, empty states, partial failure.

You won't have time to go deep on all ten. Cover each in a sentence, then spend the time where this particular problem is hard: races for the typeahead, virtualization for the feed, update frequency for the dashboard.

The five prompts below are the ones that come up most. Each outline is what a strong answer covers; say it in your own words.

Prompt 1: an autocomplete (typeahead)#

Requirements. Suggestions as the user types, keyboard navigation, selection fills the input or navigates. Ask: local data or server? How large? Recent searches? Mobile?

Data. GET /search?q=...&limit=8, returning ids and display strings. Server does the ranking.

Tree. Combobox > Input, Listbox > Option. Headless logic in a useCombobox hook so the styling can vary (Component patterns).

State. The input text is local (controlled, because each keystroke drives the query). Highlighted index and open/closed are local. Results are server cache keyed by the query. If the search page has a results view, the committed query goes in the URL.

Fetching and caching. This is where the depth is:

  • Debounce keystrokes (150 to 300 ms) or use useDeferredValue so typing stays urgent while the list lags behind (Transitions).
  • Cancel or ignore stale responses. Responses arrive out of order; "c" can come back after "crafting" and overwrite it. Abort the previous request with an AbortController in the effect cleanup, or let a query library key by query.
  • Cache by query so backspacing is instant (TanStack Query with placeholderData to keep the previous list while the next loads; Server state).
  • Minimum query length, and a prefix cache if the data is small enough to filter locally.

Rendering. A client component; the page around it can be server-rendered.

Performance. Few items, so rendering is cheap; the risks are request volume and bundle size of a heavy combobox library.

Accessibility. The WAI-ARIA combobox pattern: role="combobox" on the input with aria-expanded, aria-controls and aria-activedescendant; role="listbox" and role="option"; arrow keys, Enter, Escape; a polite live region announcing the result count. Focus stays in the input (Accessibility).

Testing. Unit-test the hook's keyboard logic; integration-test with mocked network (MSW), including out-of-order responses; one end-to-end test of the happy path.

Failure modes. Out-of-order responses, slow network (show a subtle pending state, keep old results), errors (inline message, keep typing possible), empty results, very fast typists, IME composition for non-Latin input.

Build itA typeahead that never shows stale results

Here's the core of the typeahead. The fake server is slow for short queries, as real ones often are, so if you type "c" and then quickly finish "crafting", the "c" response arrives last and overwrites the right answer. Make the list always show results for the current query. Type "c", pause a beat, then type "rafting" quickly to see the bug.

import { useEffect, useState } from "react";
import { fakeFetch } from "guide-tools";

type Book = { id: number; title: string };

// Short queries are slow here, like a server scanning more rows.
function searchBooks(q: string, signal?: AbortSignal): Promise<Book[]> {
  return fakeFetch(`/books?q=${encodeURIComponent(q)}`, { delay: 800 / q.length, signal });
}

export default function App() {
  const [query, setQuery] = useState("");
  const [results, setResults] = useState<Book[]>([]);

  useEffect(() => {
    if (!query) return;
    searchBooks(query).then(setResults);
  }, [query]);

  const shown = query ? results : [];

  return (
    <div>
      <label>
        Search books <input value={query} onChange={(e) => setQuery(e.target.value)} />
      </label>
      <ul>
        {shown.map((b) => (
          <li key={b.id}>{b.title}</li>
        ))}
      </ul>
    </div>
  );
}

Prompt 2: an infinite feed#

Requirements. A scrolling list of posts, new ones loading at the bottom, likes and comments, possibly new posts arriving at the top. Ask: how many items in a session? Media-heavy? Must it work without JavaScript or be indexable?

Data. Cursor-based pagination (GET /feed?cursor=abc), not page numbers, because items get inserted while you scroll and offsets would skip or repeat.

Tree. Feed > VirtualList > PostCard > Media, Actions, CommentPreview; a NewPostsBanner at the top.

State. Pages live in the server cache (TanStack Query's useInfiniteQuery). A like is a mutation with an optimistic update. Scroll position should survive navigating to a post and back, so cache pages and restore position rather than refetching.

Rendering. Server-render the first page for fast first paint and SEO; everything after loads client-side. With the App Router, the first page can be a Server Component passing initial data to a client list.

Performance. The hard part. Thousands of DOM nodes make scrolling janky, so virtualize (Big UI): render only what's on screen, with measured variable heights. Load the next page with an IntersectionObserver sentinel a screen before the end. Lazy-load images with fixed aspect ratios to avoid layout shift. Memoize PostCard (or let the Compiler) so a like doesn't re-render the list.

Accessibility. role="feed" with article items, aria-busy while loading, and a "Load more" button as an alternative to scroll-triggered loading. New posts appear only when the user asks (the banner), so content doesn't jump under them.

Testing. The pagination logic against a mocked API; the virtual list with a few hundred items; an end-to-end scroll test.

Failure modes. A page fails to load (inline retry at the bottom, keep what's loaded), duplicate items across pages (dedupe by id), the end of the feed, an optimistic like that fails (roll back and tell the user), memory growth in very long sessions (drop far-away pages).

Prompt 3: a real-time dashboard#

Requirements. Live metrics, charts and an alert list, updating several times a second. Ask: how many widgets? Update frequency? Must numbers be exact or is "recent" fine? Multiple tabs?

Data. An initial snapshot over HTTP, then deltas over a WebSocket or Server-Sent Events. Versioned messages so the client can detect gaps and resync.

Tree. Dashboard > Toolbar (time range, filters), WidgetGrid > Widget > Chart / Stat / AlertList.

State. This is the interesting part. The stream is an external store: the socket writes into a store outside React, and each widget subscribes to its slice with a selector through useSyncExternalStore (directly, or via Zustand) so a CPU metric update doesn't re-render the alert list (Build a store). Putting the stream in Context would re-render every widget on every message. The time range and filters go in the URL so a dashboard link is shareable.

Rendering. Client-rendered app shell; the layout and widget configuration can come from the server. Charts are client components.

Performance. Batch incoming messages and apply them once per animation frame instead of per message. Throttle chart redraws; humans can't read more than a few updates a second. Use canvas for dense charts. Mark heavy re-renders (switching time range) as transitions. Pause or slow updates when the tab is hidden.

Accessibility. Don't announce every tick. Announce only threshold alerts through a live region, give charts text summaries or table views, and make sure color isn't the only signal for status.

Testing. The store and its reducers as plain functions; widgets with a fake stream; the reconnection logic with simulated disconnects.

Failure modes. Disconnects (show "reconnecting", back off, resync from a snapshot on reconnect), out-of-order or missed messages (sequence numbers), a slow consumer falling behind (drop intermediate values, keep the latest), clock skew between server and client.

Prompt 4: a form-heavy multi-step flow#

Requirements. A five-step onboarding or checkout: personal details, address, plan, payment, review. Ask: can users go back? Save and resume? Steps that depend on earlier answers? Server-side validation?

Data. A draft resource on the server (PUT /applications/:id) so progress survives reloads and devices, then a final submit.

Tree. Wizard > StepNav, Step (one per step) > fields; ReviewStep; SubmitBar.

State. The current step goes in the URL (/apply/address), so Back, reload and analytics work. Form values live in a form library (React Hook Form) or uncontrolled inputs with FormData, not in a global store (URL and form state). One schema (Zod) per step validates on the client for fast feedback and again on the server, which is the only validation that counts. The saved draft is server state.

Fetching. Autosave each step on "Next" (and debounced while typing, if resume matters). The final submit is an Action or a Server Function with useActionState for pending and errors (Actions).

Rendering. Server-render each step page so it works before JavaScript loads; with a Server Function as the form action, submission can work before hydration too.

Performance. Usually not the bottleneck. Avoid re-rendering the whole form per keystroke (React Hook Form's subscription model does this), and code-split heavy steps like an address autocomplete or payment widget.

Accessibility. Every input has a label. Errors are linked with aria-describedby and summarized at the top on submit, with focus moved to the summary or the first invalid field. Announce step changes and move focus to the new step's heading. Don't disable the submit button as the only feedback; explain what's missing.

Testing. Schemas as unit tests; each step as an integration test with React Testing Library; one end-to-end run through the whole flow, including back navigation and a server-side validation error.

Failure modes. Server validation disagreeing with the client (show server errors on the right fields), double submission (pending state disables submit, and the server uses an idempotency key), session expiry mid-flow (draft is saved; re-auth and resume), the payment step failing after earlier steps succeeded.

Prompt 5: a large e-commerce product page#

Requirements. Images, title, price and stock, variant selection, add to cart, reviews, recommendations. Must be fast on mobile and indexable. Ask: personalized pricing? Stock accuracy? Traffic spikes?

Data. Product (mostly static), price and stock (dynamic), reviews (slow, paginated), recommendations (personalized, slowest), cart (per user).

System design: a product page, layer by layer
ProductPageGalleryProductInfoBuyBoxReviewsRecommendedPriceStockVariantsAddToCartReviewForm
Step 1 of 4

Start with the tree, drawn from the page's data: what the product is, what can be bought, what other people said, what else to show. Each box owns one piece of the screen.

Rendering. This prompt is the showcase for Server Components and streaming. The product description and images are static or cached for a long time (with Next.js Cache Components, "use cache" with a tag invalidated when the product changes; Caching in Next.js). Price and stock are dynamic per request. Reviews and recommendations stream behind their own Suspense boundaries so they can't delay the purchase path. Under partial prerendering, the static shell is served from the CDN and the dynamic holes stream in.

State. As in the diagram: the selected variant in the URL, the cart as server state with an optimistic count, gallery details local.

Performance. LCP is the hero image: serve it responsive, preload it, never lazy-load it. Keep client JavaScript to the interactive islands. Avoid layout shift by reserving space for price and reviews. Prefetch likely next pages. See Measure first.

Accessibility. Variant choices as a radio group with visible labels (not just color swatches), alt text for product images, add-to-cart confirmation in a live region, a focus-trapped and labeled dialog for the image zoom.

Testing. Visual regression for the layout, integration tests for variant selection and add to cart, an end-to-end checkout path, and performance budgets in CI (Production checklist).

Failure modes. Recommendations service down (the boundary shows nothing or a fallback; the page still sells), stock changed between view and add to cart (the server re-checks and the optimistic update rolls back with a message), a cached price after a price change (invalidate by tag on write), a traffic spike (static shell from the CDN absorbs it).

Explain it out loudDesign round: the infinite feed

"Design the frontend for an infinite social feed. You have five minutes; give me the outline and go deep on one part."

The last-hour checklist#

An hour before the interview, don't learn anything new. Rehearse the answers you're most likely to need, out loud, in the five-part shape. These are the most-asked topics, each with the ★ chapter to skim:

Then open Rehearse and answer five random questions out loud before reading the model answers. Saying an answer once is worth more than reading it three times.

Last, three things to have ready that aren't about React: a project you can describe in the five-part shape (what, how it worked, the trade-off you made, a concrete detail, what you'd change), a bug you're proud of finding, and one question for them about how their team builds frontend.

Pitfalls#

Check your understanding#

Explain it out loudFrom keystroke to pixels

"In a React 19 app, a user types one character into a search box that filters a long list. Walk me through what happens, from the keypress to the updated screen."

Explain it out loudA trap question

"We use Context for all our global state and it's slow. Should we memoize everything?"

Interview angle

Say it in 30 seconds

A strong React answer has five parts: a one-sentence definition, the mechanism, the trade-off, a concrete example, and what I'd do in production. About a minute, then stop and let the interviewer steer. Think aloud by stating assumptions and the React version, and trace code render by render. When I don't know, I say so, reason from what I do know, and say how I'd check. For system design I walk requirements, data, the component tree, state placement, fetching and caching, rendering, performance, accessibility, testing and failure modes, then go deep where the problem is hard.

Give me your mental model of React in about a minute.

intermediate

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

senior

A React page feels slow. How do you find and fix the problem?

senior

In a Next.js App Router app, trace a piece of data from the database to the screen, and then a button click that changes it.

senior

When would you not use Server Components?

senior

How do you design loading and error states across a React app?

senior

What's a React misconception you hear often, and what's actually true?

intermediate

Recap#

  • Shape every answer the same way: definition, mechanism, trade-off, example, what I'd do in production. About a minute, then stop and let them steer.
  • Think aloud: state your assumptions and version, trace code render by render, and ask one clarifying question at a real fork.
  • When you don't know, say so, reason from what you do know, and say how you'd find out. Never bluff.
  • Know the myths cold: the virtual DOM isn't faster than the DOM, derived state isn't state, memoization isn't free, Context isn't a state manager, Server Components don't replace interactive state, and key advice has no absolutes.
  • For system design, walk requirements, data, tree, state placement, fetching, rendering, performance, accessibility, testing and failure modes, then go deep where the problem is hard.

Sources#