← All topics

React Senior interview questions and answers

75 questions for a React (Senior) interview - with correct answers, explanations and links to the docs.

Take this quiz
  1. 1.Why is React's cache() useful in Server Components?
  2. 2.What is Fiber in React?
  3. 3.How does the render phase differ from the commit phase?
  4. 4.What does concurrent rendering give the user?
  5. 5.What happens during hydration?
  6. 6.Which code in render typically causes a hydration error?
  7. 7.What is selective hydration in React 18+?
  8. 8.How does streaming SSR (renderToPipeableStream) work?
  9. 9.How do Server Components differ from client components?
  10. 10.What does the 'use client' directive at the top of a file do?
  11. 11.How do you render a Server Component inside a client <Modal>?
  12. 12.Which props can't be passed from a Server Component to a Client Component?
  13. 13.What's important to remember about 'use server' functions in terms of security?
  14. 14.What is useEffectEvent for?
  15. 15.What does the <Activity mode="hidden"> component (React 19.2) do?
  16. 16.What is useImperativeHandle for?
  17. 17.What does this hook do?
  18. 18.What is tearing in concurrent rendering?
  19. 19.Which of these scenarios causes a memory leak in a React app?
  20. 20.What's the most accurate way to find which components are slow during interaction?
  21. 21.Why doesn't useContext have "selectors", and how do people work around it?
  22. 22.You need to render a list of 100,000 items. What should you do?
  23. 23.What happens to an error thrown during render if there's no error boundary above the component?
  24. 24.Why doesn't an already-shown Suspense fallback appear during a transition inside startTransition?
  25. 25.What changed in startTransition in React 19?
  26. 26.What's new about callback refs in React 19?
  27. 27.How do you set <title> and <meta> from a component in React 19 without third-party libraries?
  28. 28.Does useMemo guarantee the computation won't repeat with the same dependencies?
  29. 29.When is it acceptable to call setState directly during render?
  30. 30.When is flushSync justified?
  31. 31.What is createListenerMiddleware in Redux Toolkit for?
  32. 32.How do you do an optimistic update in RTK Query?
  33. 33.What is the signature of a Redux middleware?
  34. 34.Why don't you put promises, class instances and functions into the Redux store?
  35. 35.What is structural sharing in TanStack Query?
  36. 36.How do you correctly pass TanStack Query data loaded on the server to client components?
  37. 37.Why can't you use a single global QueryClient for all requests on the server?
  38. 38.How do you properly support request cancellation in TanStack Query?
  39. 39.How does useSuspenseQuery differ from useQuery?
  40. 40.What must you specify in useInfiniteQuery?
  41. 41.Do you need Redux or Zustand if server data is already in TanStack Query?
  42. 42."Invalid hook call" error. What's the most likely cause if the component code is correct?
  43. 43.What principle underlies React Testing Library?
  44. 44.What are headless UI components, and why are they chosen for design systems?
  45. 45.How does key on a wrapper component differ from key inside a list?
  46. 46.What are the preload and preinit APIs from react-dom in React 19 for?
  47. 47.Why can React.memo with a custom comparison function be dangerous?
  48. 48.How does React 18+ handle setState on an unmounted component?
  49. 49.What does TanStack Query give you compared to loading data in useEffect with useState?
  50. 50.When does RTK Query remove data from its cache?
  51. 51.What does prerender from react-dom/static do differently from streaming SSR?
  52. 52.What is sent to the browser when Server Components render?
  53. 53.Why does this component suspend forever (or refetch endlessly)?
  54. 54.What does useDeferredValue(query, "") with an initial value change (React 19)?
  55. 55.What does the React Compiler need from your code to optimize it safely?
  56. 56.When is suppressHydrationWarning appropriate?
  57. 57.What do the onCaughtError and onUncaughtError options of createRoot (React 19) give you?
  58. 58.Why can importing one icon from a big "barrel" file (index.ts re-exporting everything) hurt?
  59. 59.A text input at the top of a large page makes the whole page re-render on each keystroke. What is the simplest fix?
  60. 60.Why doesn't <ExpensiveTree /> re-render when ColorPicker state changes here?
  61. 61.What does a test warning "An update was not wrapped in act(...)" mean?
  62. 62.Why mock network requests with Mock Service Worker (MSW) rather than mocking fetch in each test?
  63. 63.Why does useSyncExternalStore accept a getServerSnapshot argument?
  64. 64.How do you guarantee a module with secrets is never bundled into client code?
  65. 65.Where does React (17+) attach its event listeners?
  66. 66.What does <link rel="stylesheet" href="/chart.css" precedence="default" /> inside a component do in React 19?
  67. 67.How do you avoid a waterfall when a Server Component needs two independent requests?
  68. 68.How can a Server Component start a fetch but let a Client Component wait for it?
  69. 69.How do you let users retry after an error boundary shows a fallback?
  70. 70.How do you unit-test a custom hook?
  71. 71.Why is storing JSX elements in state usually a bad idea?
  72. 72.What does Immer's produce give you for deeply nested state updates?
  73. 73.Why might onClick={() => select(item.id)} defeat memo on 1000 list rows?
  74. 74.What happened to propTypes on function components in React 19?
  75. 75.Why are error boundaries still written as classes (or provided by a library)?