ExtraBrain Interview Questions
React Interview Questions for 2026, With Answer Outlines
Short answer
Current React interviews test how well you understand rendering and state: when React keeps or resets state, why keys matter, when an effect is the wrong tool, how stale closures and fetch races happen, and how React 19 Actions replace hand-written form state. Expect questions on the React Compiler, which memoizes automatically, and on securing Server Components and Server Functions.
React interview questions for 2026: state and keys, effects, stale closures, fetch races, React 19 Actions, the React Compiler and Server Components.
React questions have shifted from “explain the virtual DOM” to debugging. You get a component where the timer freezes at 1, a form that keeps the previous user’s draft, or a search box that shows results for an old query, and you have to explain the cause in terms of how React renders. The other big topic is what React 19 and the React Compiler changed about code people wrote for years.
Each component below was rendered with React 19.2 in a DOM test environment (none of them depends on anything newer) and exercised the way a user would: typing, clicking, submitting and waiting for timers. The behavior described in the comments is what those checks showed.
State and rendering questions
Why does the form keep the previous contact’s draft?
React ties state to a component’s position in the tree. The react.dev guide on preserving and resetting state explains that the same component rendered at the same position keeps its state across re-renders, even when its props change. Switching from one contact to another renders the same Draft in the same place, so the text survives. A key gives the component an identity:
import { useState } from "react";
function Draft({ contactId }) { const [text, setText] = useState(""); return ( <textarea aria-label={`Message to ${contactId}`} value={text} onChange={(e) => setText(e.target.value)} /> );}
export default function Chat({ contactId }) { // A new key means a new Draft instance, so its state starts empty. return <Draft key={contactId} contactId={contactId} />;}The same idea explains why array indexes are poor keys for lists that reorder or filter: the key stays with the position, not the item, so state and DOM nodes attach to the wrong rows. Use a stable ID from the data.
When is useEffect the wrong tool?
When there is no external system to synchronize with. The You Might Not Need an Effect guide lists the common cases: compute derived values during render, cache expensive calculations with useMemo, reset state with a key, and put logic caused by a user action in the event handler. The classic interview example is filtered data copied into state:
import { useState } from "react";
export default function TaskList({ tasks }) { const [showDone, setShowDone] = useState(true); // Derived during render. The anti-pattern is a second useState for // `visible` plus a useEffect that copies the filtered list into it, // which renders once with stale data and can drift out of sync. const visible = showDone ? tasks : tasks.filter((task) => !task.done); return ( <> <label> <input type="checkbox" checked={showDone} onChange={(e) => setShowDone(e.target.checked)} /> Show done </label> <ul> {visible.map((task) => ( <li key={task.id}>{task.title}</li> ))} </ul> </> );}The guide also suggests measuring before memoizing: unless you’re processing thousands of items, the calculation is usually cheap enough to skip useMemo.
Effects and closures questions
Why does this timer stop at 1?
import { useEffect, useState } from "react";
export default function Stopwatch() { const [seconds, setSeconds] = useState(0); useEffect(() => { const id = setInterval(() => { setSeconds((s) => s + 1); // reads the latest value on every tick // setSeconds(seconds + 1) would freeze at 1: this closure saw seconds = 0 }, 1000); return () => clearInterval(id); // runs on unmount }, []); return <p>{seconds} s</p>;}The effect runs once, so its callback closes over the seconds from the first render, which is 0. Writing seconds + 1 sets 1 on every tick. The functional updater asks React for the current value instead. Adding seconds to the dependency array also works, but it tears down and recreates the interval every second. For effects that need the latest props without re-running, React 19.2 added useEffectEvent; the React 19.2 post warns against listing Effect Events as dependencies or using them just to silence the linter.
How do you stop old fetch responses from overwriting new ones?
import { useEffect, useState } from "react";
export default function SearchResults({ query, fetchResults }) { const [results, setResults] = useState([]); useEffect(() => { let ignore = false; fetchResults(query).then((data) => { if (!ignore) setResults(data); // drop responses for a query that's no longer current }); return () => { ignore = true; }; }, [query, fetchResults]); return ( <ul> {results.map((item) => ( <li key={item}>{item}</li> ))} </ul> );}If the response for “re” arrives after the response for “react”, the cleanup from the earlier render has already set its ignore flag, so the stale data is discarded. This is the pattern react.dev shows. Also say that a framework’s data fetching or a data library usually handles caching and races for you, and that an AbortController can cancel the request itself: call abort() in the cleanup and the pending fetch rejects with an AbortError you can ignore.
What belongs in the dependency array?
Every reactive value the effect reads: props, state and anything computed from them during render. The linter in eslint-plugin-react-hooks checks this, and silencing it usually hides a bug like the frozen timer above. If the list keeps growing or the effect re-runs too often, change the code rather than the array: move a helper function inside the effect, derive a primitive value before the effect, or read the latest value through a functional update or an Effect Event. An object or function created during render is a new value every time, so listing it makes the effect run on every render.
React 19 questions
What are Actions, and what does useActionState replace?
The React 19 release post defines Actions as async functions used in transitions that handle pending state, errors, optimistic updates and form resets for you. useActionState returns the action’s last result, a wrapped action and a pending flag:
import { useActionState } from "react";
async function saveName(previousState, formData) { const name = formData.get("name"); if (!name) return { error: "Name is required", saved: null }; await new Promise((resolve) => setTimeout(resolve, 300)); // stands in for a request return { error: null, saved: name };}
export default function NameForm() { const [state, formAction, isPending] = useActionState(saveName, { error: null, saved: null }); return ( <form action={formAction}> <input name="name" aria-label="Name" /> <button disabled={isPending}>{isPending ? "Saving..." : "Save"}</button> {state.error && <p role="alert">{state.error}</p>} {state.saved && <p>Saved {state.saved}</p>} </form> );}No useState for loading or errors, and no onSubmit with preventDefault. Passing a function to <form action> runs it as an Action and resets uncontrolled fields after success. Mention useOptimistic for showing the expected result while the request runs and useFormStatus for reading the parent form’s pending state from a design-system button.
Do you still need useMemo and useCallback?
Less often. React Compiler 1.0, released in October 2025, memoizes components and hooks automatically at build time, including cases manual hooks can’t express, such as code after an early return. It works with React 17 and later, and its lint rules ship in the recommended preset of eslint-plugin-react-hooks. The team describes useMemo, useCallback and React.memo as escape hatches for precise control, such as a memoized value used as an effect dependency, and advises testing carefully before removing existing memoization.
How do you secure Server Components and Server Functions?
Treat every Server Function as a public HTTP endpoint: validate its input and check authorization inside it, because the client can call it with any payload. Then mention December 2025. React disclosed CVE-2025-55182, an unauthenticated remote code execution flaw rated CVSS 10.0 in the React Server Components packages, first fixed in 19.0.1, 19.1.2 and 19.2.1. The advisory notes that an app could be vulnerable if it supports Server Components even without defining Server Function endpoints, and its update instructions were later revised for further CVEs, so the right answer is the current patched version, not those first minimums. Fast dependency updates are part of the answer.
What did React 19.2 and 19.3 add?
| Release | Feature | Question it prompts |
|---|---|---|
| 19.0 (Dec 2024) | Actions, use, ref as a prop | ”Build a form without useEffect” |
| Compiler 1.0 (Oct 2025) | Automatic memoization | ”Do you still write useMemo?“ |
| 19.2 (Oct 2025) | <Activity>, useEffectEvent | ”Keep a hidden tab’s state” |
| 19.3 (Sep 2026) | <ViewTransition>, Fragment refs | ”Animate a list reorder” |
<Activity mode="hidden"> hides a subtree, unmounts its effects and defers its updates while preserving its state. The React 19.3 post made <ViewTransition> and Fragment refs stable; view transitions animate only updates marked as transitions. The React blog also records that the React Foundation, announced in October 2025, launched under the Linux Foundation in February 2026.
Practice explaining renders out loud
The strongest React answers narrate the render: “this state update triggers a render, the effect’s closure still sees the old value, so…” Practice that narration on bugs from your own projects. If you rehearse with ExtraBrain, the transcript shows where you said “it re-renders” without saying why. Our Next.js interview questions cover the framework layer, and the TypeScript interview questions cover typing props and hooks. ExtraBrain is a preparation tool; follow the employer’s rules on AI during the interview itself.
Sources (checked November 23, 2026)
- react.dev, Preserving and Resetting State
- react.dev, You Might Not Need an Effect
- React blog, React 19
- React blog, React 19.2
- React blog, React Compiler v1.0
- React blog, React 19.3
- React blog, Critical Security Vulnerability in React Server Components
- React blog index
- MDN, AbortController
FAQ
Are class components still asked about?
Rarely, beyond reading legacy code and error boundaries. New code uses function components and hooks.
Should I use the React Compiler in a take-home?
If the starter project includes it, yes. Otherwise write clear code and memoize only where you can explain the cost you’re avoiding.
What is a common React mistake in interviews?
Copying props or derived data into state and syncing it with an effect. Deriving it during render is shorter and can’t drift.