React and Next.js · 49 concepts
React
How React really works in 19.x, from rendering and hooks to concurrency, Server Components and state management, at senior interview depth.
Asked in these mock interviews
Part 1 · 6 concepts
How React renders
- 01
Components, elements and JSX
A component is a function that returns a description of the UI; JSX compiles to plain function calls that create element objects, and React (not you) calls your…
- 02
Render and commit: the two phases of an update
Every screen update goes trigger, then render (React calls your components to compute the next UI; this must be pure and may be paused or thrown away), then commit…
- 03
Reconciliation and the virtual DOM
Reconciliation is how React compares the new element tree with the current one and works out the smallest set of DOM changes, using two rules: a different type at the…
- 04
Keys, identity and resetting state
A key is a child's identity among its siblings; with index keys, state and DOM stay attached to positions instead of items, and changing a key on purpose is the clean…
- 05
Fiber: how React splits rendering into units of work
Fiber is React's internal rewrite of reconciliation: each component instance is a "fiber" object linked by child, sibling and return pointers, so React can do render…
- 06
React events, delegation and portals
React attaches one listener per event type at the root container and dispatches synthetic events through the React tree, so events from a portal bubble to their React…
Part 2 · 5 concepts
State: snapshots, updates and where state lives
- 07
setState: snapshots, the update queue and batching
State is a snapshot for each render: setCount does not change count now, it queues an update; React batches all updates from one event and processes the queue in order…
- 08
How hooks store state: call order and the rules of hooks
React stores each component's hooks as an ordered list on its fiber and matches them by call index, so hooks must be called in the same order on every render: top level…
- 09
Shaping state: lifting up, derived values and immutable updates
Keep the minimum state, compute everything else during render, lift shared state to the closest common parent, and always replace objects and arrays instead of mutating…
- 10
useReducer: explicit state transitions
Use useReducer when several values change together or the next state depends on the current one through clear rules; the reducer is a pure function you can unit-test…
- 11
Context and its re-render cost
Context passes a value deep into the tree without props; every component that reads it re-renders when the value changes by Object.is, so a new object on every render…
Part 3 · 8 concepts
Effects and synchronisation
- 12
useEffect: synchronising with the outside world
useEffect runs code after React commits, to keep a component in sync with a system outside React (a socket, a timer, a browser API); its cleanup runs before the next…
- 13
Dependencies, object identity and infinite loops
React compares each dependency with Object.is, so an object, array or function created during render is "new" every time and re-runs the effect; if that effect sets…
- 14
StrictMode: why effects run twice in development
In development, StrictMode renders components twice and runs every effect setup, then cleanup, then setup again, to prove your effects clean up correctly; the fix for…
- 15
You might not need an effect
Most effects in real code should be deleted: derive data during render, handle user actions in event handlers, reset state with a key, and use a framework, query…
- 16
Stale closures in effects, timers and callbacks
Every render creates new functions that "see" that render's props and state; a callback kept from an old render (an interval started with [], a debounced handler) keeps…
- 17
useEffectEvent: separating events from effects
useEffectEvent (React 19.2) wraps logic that is fired from an effect but should not make the effect re-run, such as reading the current theme when a chat connects; it…
- 18
Fetching in effects and race conditions
When a fetch effect re-runs, an older slow response can arrive after a newer fast one and overwrite it; the effect cleanup must ignore or abort the old request, and…
- 19
useLayoutEffect and useInsertionEffect
useLayoutEffect runs after React changes the DOM but before the browser paints, and blocks paint, so it is for measuring layout and adjusting it without a visible…
Part 4 · 2 concepts
Refs and imperative code
- 20
useRef: refs vs state, usePrevious and callback refs
A ref is a mutable box ({ current }) that survives renders but does not trigger a render when changed, so use it for DOM nodes and instance values like timer ids, never…
- 21
Ref as a prop, useImperativeHandle and Fragment refs
In React 19 a function component receives ref as a normal prop, so forwardRef is no longer needed; useImperativeHandle exposes a small API (like focus()) instead of the…
Part 5 · 4 concepts
Component patterns
- 22
Designing custom hooks
A custom hook is a function starting with use that calls other hooks to share stateful logic (not state itself); a good one has a clear input/output contract, stable…
- 23
Composition: children, compound components, render props and HOCs
Prefer composition (passing components and children) over configuration props; hooks replaced most HOCs and render props for logic reuse, and compound components…
- 24
Controlled vs uncontrolled components
A controlled input gets its value from React state on every keystroke; an uncontrolled input keeps its own value in the DOM and you read it on submit (ref or FormData)…
- 25
Error boundaries
An error boundary is a class component (getDerivedStateFromError / componentDidCatch) that catches errors thrown while rendering its children and shows a fallback; it…
Part 6 · 5 concepts
Performance
- 26
Why a component re-renders
A component re-renders when its own state changes, when its parent re-renders, when a context it reads changes, or when an external store it subscribes to changes; a…
- 27
memo, useMemo and useCallback
memo skips re-rendering a component when its props are shallow-equal; useMemo caches a calculated value and useCallback caches a function identity between renders; they…
- 28
A step-by-step React performance process
Senior performance answers follow a process: reproduce and measure, find which kind of cost it is (too many renders, expensive renders, too much DOM, network…
- 29
React Compiler: automatic memoization
React Compiler 1.0 (October 2025) is a build-time tool that adds fine-grained memoization to components and hooks automatically, so new code rarely needs manual…
- 30
List virtualisation
Virtualisation renders only the rows visible in the viewport (plus a small overscan) inside a container sized for the full list, so 10,000 rows cost about as much DOM…
Part 7 · 5 concepts
Concurrent React and Suspense
- 31
Transitions and useDeferredValue
A transition marks a state update as non-urgent so React can keep the input responsive and interrupt, restart or drop that render; useTransition/startTransition wrap an…
- 32
How Suspense works
A component "suspends" when the data or code it needs is not ready; React shows the nearest <Suspense> fallback and retries rendering when the promise resolves, so…
- 33
Code splitting with lazy and Suspense
Code splitting moves code the first screen does not need into separate chunks loaded with dynamic import(); in React, lazy(() => import("./Chart")) plus a <Suspense>…
- 34
Server rendering, streaming and hydration
Server rendering sends HTML so users see content early; hydration then runs the components again in the browser and attaches event handlers to that HTML, which only…
- 35
<Activity> and <ViewTransition>
<Activity mode="hidden"> (React 19.2) hides a subtree with display: none, keeps its state and DOM, and unmounts its effects; <ViewTransition> (stable in 19.3) animates…
Part 8 · 5 concepts
React 19.x: Actions, forms and Server Components
- 36
What changed in React 19, 19.1, 19.2 and 19.3
React 19 (Dec 2024) added Actions and form APIs, use, ref as a prop and stable Server Components; 19.2 (Oct 2025) added <Activity>, useEffectEvent and Performance…
- 37
Actions, form actions, useActionState and useFormStatus
An Action is an async function run inside a transition; <form action={fn}> calls it with FormData, and useActionState(reducerAction, initialState) gives you the last…
- 38
useOptimistic: instant UI with automatic rollback
useOptimistic(value, reducer?) shows a temporary value while an Action is pending and automatically goes back to the real value when the Action finishes, so a failed…
- 39
The use() API and browser()
use(resource) reads a promise (suspending until it resolves) or a context, and unlike hooks it can be called inside conditions and loops; the promise must come from a…
- 40
Server Components, Server Functions and the directives
Server Components run only on the server (at build or request time), can be async and read data directly, and send no JavaScript; "use client" marks the module boundary…
Part 9 · 6 concepts
State management and data fetching
- 41
Choosing where state lives: server, client, URL and form state
Senior state-management answers start by classifying state: server data is a cache (TanStack Query, RTK Query, Server Components), shareable view state belongs in the…
- 42
URL as state: filters, search and pagination
Shareable view state (filters, sort, page, search query) should live in the URL query string as the single source of truth, parsed and validated into typed state, and…
- 43
External stores, useSyncExternalStore and building a mini Redux
A store outside React is just state + a reducer (or setters) + a set of listeners; useSyncExternalStore(subscribe, getSnapshot) connects it to React safely, so a…
- 44
TanStack Query: server state as a cache
TanStack Query (v5) treats server data as a cache keyed by the query key: it dedupes requests, shows cached data instantly, refetches stale data in the background…
- 45
Redux Toolkit: slices, selectors, side effects and RTK Query
Redux Toolkit (2.x) is the standard way to write Redux: configureStore sets up devtools and safety checks, createSlice uses Immer so you can write "mutating" reducers…
- 46
Zustand, Jotai and Context: picking a client-state tool
Zustand is a tiny store with selector subscriptions (no provider needed), Jotai builds state bottom-up from atoms, Redux Toolkit is the opinionated choice for large…
Part 10 · 3 concepts
Forms, TypeScript and security
- 47
Forms at scale: react-hook-form, zod and server validation
Large forms stay fast with uncontrolled inputs (react-hook-form registers inputs by ref, so typing does not re-render the form), one zod schema validates on both client…
- 48
TypeScript for React components
Type props as plain object types, reuse native element props with ComponentProps, model "either this or that" props with discriminated unions, and use generics for…
- 49
Security in React apps: XSS surfaces and Server Functions
React escapes text you render, but XSS still gets in through dangerouslySetInnerHTML, user-controlled URLs, unsafe JSON in server HTML, direct DOM writes and…
Your first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.