FlexQ

Interview questions

React interview questions and answers

A React interview checks three things: that you know how rendering and hooks really work, that you can build a small component live, and, from mid-level up, that you can explain trade-offs in state, data fetching and performance.

For live interviews: the FlexQ interview copilot for Mac or Windows, 30 free live minutes.

Updated 2026-11-23 · 23 questions · junior, mid-level, senior and a coding round · a model answer and what the interviewer is checking for each

Answers below follow current React (function components and hooks; class components only where they are still required). Say them in your own words: an interviewer can hear a memorized paragraph.

Jump to: Junior · Mid-level · Senior · Coding round · How to practice · FAQ

Junior React questions

Junior rounds check the mental model: what a component is, how data flows, and why React asks for things like keys.

1. What is JSX, and what does it compile to?

Model answer: JSX is a syntax extension that lets you write markup inside JavaScript. A compiler such as Babel, SWC or esbuild turns each tag into a function call: with the automatic runtime used since React 17 that is jsx() from react/jsx-runtime, and with the classic runtime React.createElement(). The call returns a plain object, a React element, that describes what to render. That is why attributes are camelCase (className, htmlFor) and why any JavaScript expression goes inside braces.

What the interviewer is checking: That you see JSX as JavaScript, not HTML, and know an element is a cheap description, not a DOM node.

2. What is the difference between props and state?

Model answer: Props are inputs a parent passes down; the component reads them and must not change them. State is data the component owns and changes over time with its setter, and changing it schedules a re-render. If a value can be computed from props or other state, it should not be state at all: compute it during render. Data flows down through props, and changes flow up through callbacks the parent passes in.

What the interviewer is checking: One-way data flow, and whether you avoid duplicating derived values in state.

3. Why does React need a key on list items, and when is the array index a bad key?

Model answer: Keys tell React which item is which between renders, so it can keep the right state and DOM node attached to the right item. With the index as key, inserting, removing or reordering items shifts the keys, so state such as a typed value in an input stays at the old position and ends up on the wrong item. The index is fine only for a static list that is never reordered or filtered. A stable ID from the data is the right default.

What the interviewer is checking: That you know keys are about identity across renders, not about silencing a console warning.

4. What is a controlled input, and when would you use an uncontrolled one?

Model answer: A controlled input gets its value from React state and reports changes through onChange, so state is the single source of truth and you can validate or format on every keystroke. An uncontrolled input keeps its own value in the DOM; you set a starting defaultValue and read it through a ref or from the form on submit. Uncontrolled is simpler for large forms where you only need values at submit time, and for file inputs, which are always uncontrolled.

What the interviewer is checking: Whether you can pick between the two for a reason, and know file inputs can not be controlled.

5. What does useEffect do, and when does it run?

Model answer: useEffect synchronizes a component with something outside React: a subscription, a timer, a non-React widget, a network request. It runs after React has committed the render to the screen. With a dependency array it re-runs only when one of those values changes; with an empty array, once after mount. The cleanup function runs before the next run and on unmount. In development, Strict Mode mounts components twice, running setup, cleanup and setup again, to expose effects that do not clean up.

What the interviewer is checking: That effects are for syncing with external systems, and that you understand cleanup and dependencies.

6. Why does console.log(count) right after setCount(count + 1) print the old value?

Model answer: State in a render is a snapshot: count is a constant for that render, and calling the setter only asks React to render again with a new value. React also batches updates from the same event, including inside timeouts and promises since React 18, and renders once afterwards. The new value appears in the next render. If the next value depends on the previous one, use the updater form setCount(c => c + 1).

What the interviewer is checking: The snapshot model of state, which explains most beginner bugs in React.

7. How does a child component send data back to its parent?

Model answer: The parent passes a callback as a prop, and the child calls it with the data, for example onSelect(item). The parent then updates its own state, and the new value flows back down as props. If two siblings need the same data, the state moves up to their closest common parent, which passes it down to both. Context is for data many distant components need, not a replacement for passing a prop one or two levels.

What the interviewer is checking: Lifting state up, and restraint about reaching for context or a global store.

Mid-level React questions

Mid-level questions are about hooks you have used in production, the bugs they cause, and the reasons behind your choices.

8. What is the difference between useMemo, useCallback and React.memo?

Model answer: useMemo caches the result of a calculation between renders until its dependencies change. useCallback caches a function itself; useCallback(fn, deps) is the same as useMemo(() => fn, deps). React.memo wraps a component so it skips re-rendering when its props are equal to the last ones, compared one by one with Object.is. They work together: memo on a child only helps if the objects and functions you pass it keep the same identity, which is what the two hooks are for. Where a project uses the React Compiler, much of this memoization is added automatically.

What the interviewer is checking: That you know what each one caches, and use them after measuring rather than everywhere.

9. What is the performance trap with React Context, and how do you avoid it?

Model answer: Every component that reads a context re-renders when the context value changes, and the value is compared by identity. Passing a new object literal such as value={{ user, setUser }} on every render of the provider re-renders all consumers each time. Memoize the value with useMemo, split rarely and often changing data into separate contexts, and keep fast-changing state such as a text field out of context entirely.

What the interviewer is checking: Whether you have seen context re-render a large tree and know the fixes.

10. How would you fetch data in a component, and what goes wrong with a naive useEffect fetch?

Model answer: A naive effect that fetches and sets state has a race: if id changes quickly, an older response can arrive last and overwrite the newer one. It also has no caching, no deduplication between components, and it starts only after render, which creates request waterfalls. In an effect, cancel or ignore the stale request in the cleanup. In a real app I prefer the framework's data loading or a library such as TanStack Query, which handles caching, retries and refetching.

useEffect(() => {
  const controller = new AbortController();
  fetch(`/api/users/${id}`, { signal: controller.signal })
    .then((res) => res.json())
    .then(setUser)
    .catch((err) => {
      if (err.name !== 'AbortError') setError(err);
    });
  return () => controller.abort();
}, [id]);

What the interviewer is checking: That you spot the race condition and know when to stop hand-rolling data fetching.

11. What are the rules of hooks, and why do they exist?

Model answer: Call hooks only at the top level of a function component or a custom hook: never inside conditions, loops, nested functions or after an early return. React does not know hooks by name; it matches each call to its stored state by the order of calls in a render. If a condition skips a hook on one render, every hook after it reads the wrong state. The ESLint plugin eslint-plugin-react-hooks enforces the rules and checks effect dependencies.

What the interviewer is checking: That you know the reason (call order), not just the rule.

12. When do you use useRef instead of useState?

Model answer: Use a ref for a value that must survive re-renders but should not cause one when it changes: a timer ID, the previous value of a prop, an instance of a third-party widget, or a DOM node. Changing ref.current does not re-render, so a ref is wrong for anything the screen shows. Avoid reading or writing ref.current during render, because the result is then unpredictable; do it in effects and event handlers.

What the interviewer is checking: Whether you know what triggers a render and what does not.

13. Write a custom hook that debounces a value.

Model answer: A custom hook is a function whose name starts with use and that calls other hooks, so it can share stateful logic without sharing state. This one returns the value only after it has stopped changing for delay milliseconds. Each change starts a new timer and the cleanup clears the previous one, so only the last value gets through. A search box can then fetch on the debounced value instead of on every keystroke.

function useDebouncedValue(value, delay) {
  const [debounced, setDebounced] = useState(value);
  useEffect(() => {
    const id = setTimeout(() => setDebounced(value), delay);
    return () => clearTimeout(id);
  }, [value, delay]);
  return debounced;
}

What the interviewer is checking: Effect cleanup in practice, and whether you can extract reusable logic.

14. What does an error boundary catch, and what does it not?

Model answer: An error boundary catches errors thrown while rendering, in lifecycle methods and in constructors of the components below it, and shows a fallback instead of unmounting the whole app. It is still a class component with static getDerivedStateFromError and usually componentDidCatch for logging; many teams use the react-error-boundary package. It does not catch errors in event handlers, in asynchronous code such as timeouts or promise callbacks, during server rendering, or in the boundary itself. Those need ordinary try/catch or a global handler.

What the interviewer is checking: Precise knowledge of the limits, which is where production crashes come from.

15. What is the difference between useEffect and useLayoutEffect?

Model answer: Both run after React updates the DOM. useLayoutEffect runs synchronously before the browser paints, so you can measure layout and adjust, for example positioning a tooltip, without the user seeing a flicker. useEffect usually runs after paint and does not block it. Because useLayoutEffect blocks painting, use it only for measuring and adjusting layout, and useEffect for everything else.

What the interviewer is checking: Whether you understand the timing against the browser paint.

Senior React questions

Senior questions test how React works underneath and how you make a large app fast and maintainable.

16. Explain reconciliation. What happens when the element type at a position changes?

Model answer: After a render, React compares the new element tree with the previous one. Where the type and key at a position match, it keeps the component and its state and updates the DOM node with the changed props. Where the type changes, for example a div becomes a section or one component becomes another, React unmounts the whole old subtree, state included, and mounts a new one. Since the Fiber rewrite, the render phase can be split into chunks and interrupted, while the commit that touches the DOM stays synchronous.

What the interviewer is checking: That you can predict when state is kept or lost, which explains many subtle bugs.

17. What problem do useTransition and useDeferredValue solve?

Model answer: They mark some updates as non-urgent. Typing into an input is urgent; re-rendering a big filtered list is not. With startTransition(() => setFilter(text)), or by rendering the list from useDeferredValue(text), React can interrupt the slow render to handle the next keystroke and show the old list until the new one is ready. This is different from debouncing: no fixed delay, and the work starts at once on a fast device.

What the interviewer is checking: Whether you understand concurrent rendering as prioritization, not as making code faster.

18. What are React Server Components, and how are they different from server-side rendering?

Model answer: Server Components run only on the server or at build time. Their code is never sent to the browser, they can be async and read data directly, and they can not use state, effects or browser APIs. Interactive parts are Client Components, marked with the 'use client' directive at the top of a file. SSR is a different thing: it renders components, including Client Components, to HTML for a fast first paint, and the browser then hydrates them. Frameworks such as Next.js use both together.

What the interviewer is checking: That you can separate where code runs from how the first HTML is produced.

19. What is hydration, and what causes a hydration mismatch?

Model answer: Hydration is React attaching event handlers and state to HTML that was rendered on the server, expecting the same tree the client would render. A mismatch happens when the first client render differs: reading window or localStorage during render, Date.now() or Math.random() in output, locale-dependent formatting, or invalid HTML nesting such as a div inside a p that the browser rearranges. Fix it by rendering the same output first and moving client-only values into an effect, and use useId for generated IDs.

What the interviewer is checking: Real SSR experience: these bugs only make sense once you have debugged one.

20. A React screen feels slow. How do you find the cause and fix it?

Model answer: I record the interaction with the React DevTools Profiler to see which components render, how often and why, and with the browser Performance panel to see long tasks. Common fixes, in order: move state down so fewer components re-render, stop passing new objects and functions to memoized children, split a busy context, virtualize long lists, and move non-urgent updates into a transition. If the cost is not React at all but a heavy calculation, I memoize it or move it to a web worker. Then I measure again.

What the interviewer is checking: A measure-first habit and knowledge of the usual causes, not a list of hooks.

21. How do you design the API of a reusable component, such as a Tabs or Select, for many teams?

Model answer: I start from how it will be used and keep the common case short. Compound components (Tabs, Tabs.List, Tabs.Tab, Tabs.Panel) sharing state through context keep markup flexible without a long list of props. I support both controlled and uncontrolled use (value with onChange, or defaultValue), forward refs and pass through native props. Keyboard and ARIA behavior is built in and tested, because every team re-implementing it is how accessibility breaks.

What the interviewer is checking: API design judgment: flexibility, sensible defaults and accessibility owned by the library.

React coding round

Live coding usually means a small component in 30 to 45 minutes. Talk while you type: state the data shape first, then build the simplest version that works, then improve it.

22. Build a todo list where you can add, complete and delete items.

Model answer: I keep the list in one state array and never mutate it: adding creates a new array, toggling maps to a new object, deleting filters. Each item has a stable ID for its key; crypto.randomUUID() works in modern browsers on HTTPS or localhost. The input is controlled and the form handles Enter for free. The delete button has type="button" so it does not submit the form. Next I would mention persisting to localStorage and extracting a useTodos hook.

function Todos() {
  const [todos, setTodos] = useState([]);
  const [text, setText] = useState('');

  function add(e) {
    e.preventDefault();
    if (!text.trim()) return;
    setTodos((t) => [...t, { id: crypto.randomUUID(), text, done: false }]);
    setText('');
  }
  const toggle = (id) =>
    setTodos((t) => t.map((x) => (x.id === id ? { ...x, done: !x.done } : x)));
  const remove = (id) => setTodos((t) => t.filter((x) => x.id !== id));

  return (
    <form onSubmit={add}>
      <input value={text} onChange={(e) => setText(e.target.value)} aria-label="New todo" />
      <button>Add</button>
      <ul>
        {todos.map((x) => (
          <li key={x.id}>
            <label>
              <input type="checkbox" checked={x.done} onChange={() => toggle(x.id)} />
              {x.text}
            </label>
            <button type="button" onClick={() => remove(x.id)}>Delete</button>
          </li>
        ))}
      </ul>
    </form>
  );
}

What the interviewer is checking: Immutable updates, stable keys, a working form and talking through edge cases.

23. What does this component log, and what does the button show after one click?

Model answer: It logs 0, and the button then shows 1, not 3. All three calls read count from the same render snapshot, where it is 0, so each asks React to set it to 1. The log runs before the re-render, so it still sees 0. To add three, use the updater form three times, setCount(c => c + 1), because each updater receives the result of the previous one.

function Counter() {
  const [count, setCount] = useState(0);
  function handleClick() {
    setCount(count + 1);
    setCount(count + 1);
    setCount(count + 1);
    console.log(count);
  }
  return <button onClick={handleClick}>{count}</button>;
}

What the interviewer is checking: Whether the snapshot and batching model is solid enough to predict output.

How to practice

Pick the five questions you would least like to get and answer each out loud in under two minutes, then build the coding-round todo list from scratch with a timer running. Rehearse out loud with the free voice mock interviewer at interview.flexq.app: paste the job description, add your résumé if you like, and answer by voice (typing works too). It follows up where an answer is thin and ends with a scored report that quotes your answers back. Three mock interviews are free with an email sign-up, no card.

During the real interview, the FlexQ interview copilot can show short cues on the interviewer's questions, grounded in your résumé and the job post, and you answer in your own words. Follow the rules of the company you're interviewing with.


Practice a free mock interview

Paste a React job description and the mock interviewer asks questions like these and follows up on your answers. Three mock interviews are free with an email sign-up, no card.

For live interviews: the FlexQ interview copilot for Mac or Windows, 30 free live minutes.

On the real call

FlexQ also has a live copilot for macOS and Windows. Add your résumé and the job description, and when a question like these lands it shows a short cue from your own experience, so you answer in your own words. Your first 30 live minutes are free. Get FlexQ.

FAQ

What React topics come up most in interviews?

Hooks (useState, useEffect, useRef, memoization), keys and re-rendering, state management and data fetching, and a small live component. Senior loops add performance, Server Components and component API design.

Do I still need to know class components?

Know them well enough to read old code and to write an error boundary, which still needs a class. New code and most interview questions use function components and hooks.

Should I learn Redux for a React interview?

Learn when a global store is worth it and what it costs, and know one option such as Redux Toolkit or Zustand. Most interviewers care more that you keep server data in a query cache and local state local.

Will I have to code React live?

Often, yes: a small component such as a todo list, a search box, tabs or a modal, sometimes in a browser editor without autocomplete. Practice building one from an empty file and talking it through as you go.

How long does it take to prepare for a React interview?

If you use React at work, one to two weeks of answering these questions out loud and building two or three components from scratch is a common plan. Spend the most time on the areas you use least at work.

Related

Frontend topics: JavaScript · TypeScript · Webpack, Vite and tooling · Frontend system design · Frontend developer

More: Software engineer questions · System design interview questions · "Tell me about yourself" · Practice out loud · All interview questions