React Developer interview question · Most asked

A React page with a long list becomes slow when typing in a search box. How do you find and fix the problem?

Scenario Asked in Frontend Engineer · Full Stack Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Profile before changing code: the React DevTools Profiler shows which components re-render on each keystroke and how long they take. Typical fixes are to stop the whole list re-rendering (memoise rows, keep state close to where it's used), render only visible rows (virtualisation), and keep typing responsive with useDeferredValue or useTransition while the filtered list updates.

Longer Answer

  • Causes: search state stored high in the tree so every keystroke re-renders the page; new object or function props each render defeating memo; expensive filtering on every render; thousands of DOM nodes.
  • Fixes: move state down or split components; React.memo for rows with stable props (useCallback, useMemo where it matters, or the React Compiler); useMemo for the filtered array; virtualise with TanStack Virtual or react-window; useDeferredValue(query) so the input updates immediately.
  • Measure again: Profiler and the browser Performance panel (long tasks, INP).
  • For very large data, filter on the server or in a web worker.

Key Points

  • Profile first.
  • Keep state close to where it's used.
  • Memoise rows; stable props.
  • Virtualise long lists.
  • useDeferredValue keeps input responsive.

Explanation

What interviewers look for

Measuring first, then picking the right fix among state placement, memoisation, virtualisation and concurrent features.

More React Developer questions

← All React Developer questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake