React Interview Questions: Hooks, Rendering, and Effects Quiz

Reviewed by Mark Dickie · Last updated

4 questions on this page you can answer and see marked on the spot. Go to the first one

React is a JavaScript library for building user interfaces out of components that hold their own state. Interviewers mostly test how data flows down a component tree, when a re-render happens, and how side effects stay in sync with that data. Expect to explain useState and useEffect, why list items need stable keys, and how React reconciles its element tree with the DOM. Most lost points come from effect dependencies and stale closures.

TopicWhat interviewers check
useState updatesFunctional updates like setCount(c => c + 1), and why reads right after a setter still show the old value
useEffect dependency arrayMissing dependencies that leave stale values, and cleanup functions for subscriptions and timers
Keys in listsWhy index keys break when items are reordered, inserted, or removed
useMemo and useCallbackWhen memoization prevents re-renders, and when it adds cost with no measurable gain
useTransition and useDeferredValueKeeping typing responsive while a slow list re-renders
Actions and useActionState (React 19)How form actions track pending and error state without manual flags

How do you practise React for an interview?

  1. Build a todo list, then add a filter without re-rendering every row. Explain which props change and why memo and stable keys matter.
  2. Write a component that fetches by an id prop with useEffect. Handle the case where the id changes before the first request finishes, and add a cleanup.
  3. Rebuild a sign-up form twice, once as a controlled input and once with a React 19 action and useActionState, then compare the code paths.
  4. Trace out loud what happens on each render when a context value changes and a child reads it through useContext.

Key facts

  • Tarmac has 248 React interview questions on this topic, 10 of them on this page, at difficulty 1–4 of 5.
  • Tarmac tracked 1,185 job postings asking for React in November 2026.
  • Roles asking for React advertise a median base salary of £75,000, across 477 job postings as of November 2026.
  • Tarmac last reviewed these React interview questions on 2 November 2026.

At a glance

Questions10 shown · 248 in the bank
Difficulty1–4 of 5
FormatsMultiple choice, Fill in the blank, Code output, Flashcard, Short answer, Find the bug, Multiple answer, Ordering, True / false, Coding exercise
Interactive1 run your code against tests, in the app

What you'll review

  1. usecontext
  2. external stores
  3. reconciliation
  4. lifting state
  5. keys
  6. useeffect deps
  7. effect races

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

Consider the following component tree (React 18, rendered without React.StrictMode):#

Options

Show answer

1 time — React.memo still skips the parent-driven render, but the Provider's value is a new object on every App render, so React compares it by reference, finds it changed, and schedules a re-render of ThemedButton through its context subscription.

Why:

Incrementing count re-renders App, which creates a new { theme, setTheme } object for the Provider's value. When a Provider renders, React compares the old and new value with Object.is; the new object literal is a different reference, so every component that reads this context via useContext is scheduled to re-render. ThemedButton receives no props, so React.memo would otherwise skip it, but that memo check only governs parent-driven renders, not context-driven ones. With StrictMode off, the console logs once per click. Memoizing the value with useMemo (or splitting contexts) would prevent this.

In React 18+, the built-in hook for subscribing a component to an external store takes a subscribe function and a getSnapshot function. Assume the hook is imported from 'react' and myStore is defined as shown below. Fill in the hook name as _____ and the store property that registers listeners as _____.#

Show answer

In React 18+, the built-in hook for subscribing a component to an external store takes a subscribe function and a getSnapshot function. Assume the hook is imported from 'react' and myStore is defined as shown below. Fill in the hook name as useSyncExternalStore and the store property that registers listeners as subscribe.

const myStore = {
  subscribe(callback) {
    // register callback; return an unsubscribe function
    return () => {};
  },
  getSnapshot() {
    return 0;
  }
};

function Counter() {
  const count = **useSyncExternalStore**(
    myStore.**subscribe**,
    myStore.getSnapshot
  );
  return <div>{count}</div>;
}
Why:

The React 18+ hook for external stores is useSyncExternalStore, and it is called with a subscribe function followed by a getSnapshot function. In the given myStore object, the method that registers a listener is named subscribe, so the second blank is subscribe, and the call becomes useSyncExternalStore(myStore.subscribe, myStore.getSnapshot). Because the store defines its listener registration as subscribe in the code shown, that name is the only one that wires the component to the store correctly.

What is rendered to the screen (as visible UI text) the first time this component mounts in a standard React 18 production environment (no Strict Mode)?#

import React, { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);

  console.log('render');

  return (
    <div>
      <p>{count}</p>
      <button onClick={() => setCount(count)}>Click me</button>
    </div>
  );
}

export default Counter;
Show answer
0
Click me
Why:

On the initial mount the component renders once. useState(0) initialises count to 0, so <p>{count}</p> displays 0 and the button displays its label Click me. The question asks only about the visible DOM output on first mount, which is unambiguous regardless of Strict Mode or bailout behaviour: the user sees 0 and the button text Click me.

What is the difference between state and props?#

Show answer

Props are inputs passed in by a parent and are read-only to the receiving component. State is data the component owns and can change over time (via its setter), triggering a re-render.

Why:

Data flows down as props; a component manages its own state. Lifting state up means moving shared state to a common ancestor and passing it back down as props.

Why does React need a key on list items, and what makes a good key?#

Show answer

Keys give each list item a stable identity so React can match elements across renders during reconciliation, preserving their state and minimizing DOM work. A good key is stable and unique among siblings — typically a data id — not the array index when the list can reorder.

Why:

Without stable keys React falls back to index matching, which moves state to the wrong items when the list changes. Keys are about identity, not ordering.

The AuthProvider below causes all context consumers to re-render unnecessarily on every parent render, even when user and dispatch haven't changed. Identify the buggy line.#

function AuthProvider({ children }) {
  const [user, dispatch] = React.useReducer(authReducer, null);

  const value = { user, dispatch };

  return (
    <AuthContext.Provider value={value}>
      {children}
    </AuthContext.Provider>
  );
}
Show answer

The bug is on line 4.

Why:

The bug is on line 4: const value = { user, dispatch }; creates a new object reference on every render of AuthProvider. Because useContext compares context values by reference (Object.is), every consumer re-renders whenever AuthProvider re-renders for any reason — even if user and dispatch haven't changed. The fix is to wrap the value in useMemo: const value = React.useMemo(() => ({ user, dispatch }), [user, dispatch]);. The dispatch function from useReducer is stable across renders, and user changing is a legitimate reason to re-render consumers, so the memoized value only changes when it should.

You have a large React application using a single AppContext that holds both state (frequently updated) and dispatch (stable). Many components deep in the tree only need to call dispatch but are re-rendering on every state change because they consume AppContext via useContext.#

Options

Pick every one that applies.

Show answer

The two valid React techniques are splitting the context into separate state and dispatch contexts, and subscribing state readers through an external store with useSyncExternalStore and a selector. Both keep dispatch-only components from being notified when state changes. Wrapping the combined value in useMemo or in React.memo does not work, because a useContext consumer re-renders whenever its context value changes.

Why:

Splitting the context into a state context and a dispatch context is the standard fix: the dispatch from useReducer is referentially stable, so a component that only reads the dispatch context is not re-rendered when the state context value changes. Using useSyncExternalStore with a selector is also valid, because a component subscribes only to the slice it selects and a dispatch-only component that never selects state is not notified when that state changes. Memoizing the combined value with useMemo keyed on state still gives a new value whenever state changes, so every consumer of the combined context re-renders. React.memo does not help here: a component that calls useContext is re-rendered by React whenever the value of the context it reads changes, regardless of whether its props changed.

A component has the following effect:#

Put these in order

Show answer

The exact console output order is: effect 0, then cleanup 0, then effect 1, then cleanup 1. On mount, the effect runs once with count at 0. When count changes to 1, React runs the previous cleanup before firing the new effect. On unmount, the final cleanup runs. This before-next-effect ordering is what lets you cancel stale work such as an in-flight fetch.

Why:

The useEffect cleanup function returned from a prior effect run is called before the next effect fires (when deps change) and also on unmount. So the sequence is: mount → effect-1 runs; dep changes → cleanup-1 runs, then effect-2 runs; unmount → cleanup-2 runs. This ordering is critical for avoiding race conditions, for example cancelling a previous fetch before starting a new one. The AbortController pattern exploits this: the cleanup aborts the in-flight request from the previous render cycle.

Consider the following React code:#

Options

Show answer

Child will re-render every time the button is clicked, so the statement is False. Although items is stabilized by useMemo and passes React.memo's shallow comparison, the style prop is an inline object literal ({ color: 'red' }) that creates a new reference on every parent render. React.memo performs referential equality checks (===) on each prop, so the changed style reference causes Child to re-render despite the memo wrapper.

Why:

This question tests understanding of React's fiber bailout mechanism and referential equality. React.memo wraps Child and performs a shallow prop comparison. On the second render triggered by setCount, style is an object literal { color: 'red' } created inline. Even though its shape and values are identical to the previous render's object, it is a new reference each time — so the shallow comparison (===) fails, and Child re-renders. items is defined with useMemo and has no changing dependencies, so it retains the same reference and passes the memo check alone. But because style fails, Child re-renders regardless. The fix would be to also memoize style with useMemo or useCallback. The correct answer is that Child does re-render on every parent render, despite React.memo.

Effect races in React: when a useEffect fetches data keyed on a prop, each re-run starts a new request and its cleanup marks the previous request as stale. A stale response must not overwrite the displayed value.#

Starter code

function finalDisplayedValue(events) {
  let shown = null;
  for (const e of events) {
    if (e.type === 'resolve') shown = e.value;
  }
  return shown;
}

Your solution must pass

  • latest request wins even though stale one resolves last
  • single request resolves

This one is written and run, not read. Solve it in the app and your code is executed against these tests and the hidden ones.

Sources

The official documentation these questions are checked against:

Related interview questions

Job market

See react salaries and hiring demand from live job postings.

The other 238 questions

This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 238 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 answers per 30 days, each marked with written feedback

Interview booked? Practise the job ad instead

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.