Autocoder

React Interview Questions and Answers (React 19)

Last updated 2026-11-19

React interviews have moved beyond "what is the virtual DOM". Interviewers now ask how rendering really works, why a component re-renders, how data flows with Server Components and what React 19 changed about forms, refs and async data. This page concentrates on those concepts. Hooks are covered in depth on the separate React Hooks interview questions page.

Every answer assumes React 19. Where older behaviour differs, such as forwardRef or the lack of the use API, it is noted so you can answer correctly if an interviewer's codebase is on an earlier version. For the interview process, see how to crack a React interview.

Version coveredReact 19 (with notes on 18 differences)
FocusRendering, reconciliation, components, Server Components, Actions
Questions here18

The mental model to carry into the room

A React component is a function from props and state to a description of the UI. React calls it, compares the result with the previous result and applies the minimal DOM changes. Almost every tricky question, from stale state to unnecessary re-renders, follows from three facts: render must be pure, state updates are scheduled, not immediate, and identity (position and key) decides whether state is kept.

What changed in React 19

React Interview Questions and Answers (React 19): questions with worked answers

  1. 1

    What is the virtual DOM and what is reconciliation?

    easy

    The virtual DOM is the tree of plain objects, React elements, that components return. On each update React builds a new tree and diffs it against the previous one, then applies only the needed changes to the real DOM. The diff assumes elements of different types produce different trees, and uses keys to match list items. The aim is correctness with minimal DOM writes, not magic speed, and rendering alone is not free.

  2. 2

    Why do lists need a key, and why is the array index a poor key?

    easy

    Keys let React match items between renders, so it can preserve state and reorder DOM nodes instead of recreating them. Use a stable unique ID from the data. With index keys, inserting or removing an item shifts every following index, so input values and component state attach to the wrong rows. Index keys are acceptable only for static lists that never reorder.

    javascript
    {todos.map(t => (
      <TodoItem key={t.id} todo={t} />
    ))}
  3. 3

    Controlled versus uncontrolled components?

    easy

    A controlled input has its value held in React state and updated through onChange, so React is the single source of truth and you can validate on every keystroke. An uncontrolled input keeps its value in the DOM, and you read it through a ref or FormData when needed. Uncontrolled is simpler and fewer re-renders for plain forms, and in React 19 form actions read values from FormData directly.

  4. 4

    Why does setState not update the variable immediately?

    medium

    State is a snapshot for each render. Calling the setter schedules a re-render, and the current render keeps seeing the old value. React 18 and 19 batch updates in event handlers, timeouts and promises. If the next value depends on the previous one, pass an updater function so each call sees the latest state.

    javascript
    setCount(count + 1);
    setCount(count + 1);       // still +1 in total
    setCount(c => c + 1);
    setCount(c => c + 1);      // +2 in total
  5. 5

    When does a component re-render, and how do you avoid wasted renders?

    medium

    It re-renders when its state changes, when its parent re-renders, or when a context it reads changes. Props being equal does not stop it unless you wrap it in React.memo. First fix the structure: move state down to where it is used, or pass children as props so they are not recreated. Use memo, useMemo and useCallback only after measuring. React Compiler can add this memoisation automatically.

  6. 6

    What does StrictMode do in development?

    medium

    It renders components twice and runs effects mount, unmount, mount again, to expose impure render logic and missing cleanup. It also checks for deprecated APIs. None of this happens in production. If an effect breaks after the double run, the bug is real: the effect lacks a cleanup, such as unsubscribing or aborting a fetch.

  7. 7

    How do you share state between distant components?

    medium

    Lift the state to the nearest common ancestor and pass it down. For deep trees use context, remembering that every consumer re-renders when the value changes, so split contexts and memoise the value. For frequently changing or complex client state use a store such as Zustand or Redux Toolkit, and for server data use TanStack Query. See Redux interview questions.

  8. 8

    What are error boundaries and what do they not catch?

    medium

    An error boundary is a class component with getDerivedStateFromError or componentDidCatch that renders a fallback when a descendant throws during rendering, in lifecycle methods or in constructors. It does not catch errors in event handlers, async code, server rendering or in the boundary itself. Use try/catch for handlers. In React 19 you can also pass onCaughtError and onUncaughtError to createRoot for reporting. The react-error-boundary package gives a function-component API.

  9. 9

    How does Suspense work, and what does the use API do?

    medium

    A component can suspend while it waits for something, and the nearest Suspense boundary shows its fallback. In React 19, use(promise) reads a promise during render and suspends until it resolves, and unlike hooks it may be called conditionally. The promise must be stable across renders, so create it in a parent, a cache or a Server Component, not inline in the component that calls use.

    javascript
    function Comments({ commentsPromise }) {
      const comments = use(commentsPromise);
      return comments.map(c => <p key={c.id}>{c.text}</p>);
    }
    // <Suspense fallback={<Spinner />}><Comments commentsPromise={p} /></Suspense>
  10. 10

    What are Actions in React 19 and how does useActionState work?

    medium

    An Action is an async function you pass to a form action prop or run inside a transition. React tracks the pending state, handles errors and resets uncontrolled form fields after success. useActionState wraps an action and returns the latest result, a wrapped action to pass to the form, and an isPending flag. It removes hand-written loading and error state for typical form submissions.

    javascript
    function AddName() {
      const [error, submit, isPending] = useActionState(async (prev, formData) => {
        const err = await saveName(formData.get('name'));
        return err ?? null;
      }, null);
      return (
        <form action={submit}>
          <input name="name" />
          <button disabled={isPending}>Save</button>
          {error && <p>{error}</p>}
        </form>
      );
    }
  11. 11

    What is useOptimistic for?

    medium

    useOptimistic takes the real state and returns a copy that you can update instantly while an async action runs. When the action finishes, React discards the optimistic value and shows the real state, which gives automatic rollback on failure. Typical use is showing a sent chat message or a toggled like immediately.

  12. 12

    What changed with refs in React 19?

    medium

    Function components now receive ref as an ordinary prop, so you no longer wrap them in forwardRef, which is deprecated and will be removed in a later major. Ref callbacks can also return a cleanup function that runs when the element detaches. Class components still do not receive ref as a prop.

    javascript
    function FancyInput({ ref, ...props }) {
      return <input ref={ref} {...props} />;
    }
  13. 13

    What are React Server Components?

    medium

    Server Components render only on the server, at build time or per request, and send serialised output to the client. They can read databases or files directly, and their code never ships in the JavaScript bundle. They cannot use state, effects or browser APIs. A file marked with the use client directive defines a client boundary. Server Functions, marked use server, let client code call server logic. See Next.js interview questions.

  14. 14

    Explain how React decides to keep or reset state.

    hard

    State belongs to a position in the render tree, identified by component type and key. If the same type renders at the same position, state is kept even when props change. If the type or key changes, React unmounts the old subtree and mounts a new one with fresh state. So changing key resets a form, and defining a component inside another component causes a new type on every render and loses state.

  15. 15

    What is concurrent rendering and what do useTransition and useDeferredValue do?

    hard

    Concurrent rendering lets React prepare an update in the background and interrupt it for more urgent work such as typing. useTransition marks a state update as non-urgent, giving an isPending flag, so a heavy list filters without freezing the input. useDeferredValue gives you a lagging copy of a value for the same purpose when you do not control the setter. They do not make slow code faster, they only prioritise.

  16. 16

    How do you avoid the effect-for-everything trap?

    hard

    Do not use useEffect to derive data from props or state: compute it during render. Do not use it to respond to a user event: put the logic in the handler. Do not use it to reset state when a prop changes: use a key. Use effects only to synchronise with something outside React, such as a subscription, a timer or a non-React widget, and always return cleanup.

  17. 17

    How would you render a very large list efficiently?

    hard

    Render only what is visible by virtualising: libraries such as TanStack Virtual or react-window mount a few dozen rows and swap them as you scroll. Combine it with stable keys, memoised row components and pagination or infinite loading from the server. Measuring with the React DevTools Profiler shows whether rendering or data fetching is the real bottleneck.

  18. 18

    What does React Compiler change about useMemo and useCallback?

    hard

    React Compiler is a build-time tool that analyses components and memoises values and functions automatically, provided the code follows the Rules of React, such as pure rendering. Most manual useMemo, useCallback and memo calls become unnecessary in code it compiles. They remain valid, and you may keep them where you need a stable identity for an effect dependency. It is opt-in and works with an ESLint plugin that flags rule violations.

  19. 19

    How would you test a React component?

    hard

    Use React Testing Library with Vitest or Jest, render the component and query by role and label as a user would, then simulate interactions with user-event and assert on visible output. Avoid testing implementation details such as internal state. Mock network calls at the boundary with Mock Service Worker. Cover critical journeys end to end with Playwright.

Frequently asked questions

What React version should I prepare for?

React 19 for new roles, while knowing React 18 behaviour, because many production codebases have not upgraded. Be clear which features, such as use and useActionState, need 19.

Are class components still asked about?

Briefly. Know lifecycle methods mapping to effects, and that error boundaries still require a class. New code uses function components.

Do I need to know Next.js for React interviews?

Many React jobs use Next.js, so understand Server Components and routing at a basic level, but a pure React round focuses on rendering, hooks and state.

What coding task is common in a React round?

Building a small component such as a todo list, search with debounce, tabs, accordion or infinite scroll, usually in 45 to 60 minutes.

Related guides

More in Role-wise Interview Questions by Job and Tech Stack

See all in this section