React Curriculum

React Hooks Interview Questions: useState & useEffect

React hooks interview questions are everywhere, because hooks are the foundation of modern React development. FAANG interview panels evaluate whether you truly grasp the synchronization mental model of useEffect rather than treating it as a drop-in replacement for componentDidMount or componentDidUpdate.

These lessons break down lazy initial state evaluation, race conditions handled via AbortController cleanups, infinite re-render loops caused by object dependencies, and how useRef provides mutable container persistence without triggering component re-renders.

React Hooks Interview Questions: 6 lessons

#01
useState Internals, Lazy Init & State Resetting
MediumFree

useState persists state across renders in a linked list of hook slots attached to the component Fiber. Lazy initial state (useState(() => init())) runs expensive computations once on mount rather than on every render, and key props cleanly reset component state.

#02
useEffect Mental Model: Synchronization
MediumFree

useEffect in React synchronizes your component with an external system (browser DOM, network, timers, or third-party widgets) outside of React, and the useEffect dependency array decides when that synchronization runs again. It runs after the browser paints so it never blocks layout rendering, comparing dependencies using Object.is.

#03
useEffect Anti-Patterns & Re-render Traps
MediumFree

Common useEffect traps include infinite re-render loops caused by updating state dependencies unconditionally, memory leaks from missing cleanups, and stale closures. In React 18 StrictMode, effects run mount -> cleanup -> mount to surface cleanup bugs.

#04
Effect Cleanups & Race Conditions
HardFree

Race conditions occur when asynchronous requests resolve out of order (e.g., Query A sent before Query B, but B finishes before A). In useEffect, race conditions are solved using an active/ignore boolean flag or by canceling the in-flight request via AbortController in the cleanup function.

#05
useRef: DOM Access & Mutable Containers
MediumFree

useRef in React returns a plain JavaScript object with a persistent { current: value } property that survives across renders without triggering a re-render when mutated. It is used for directly referencing DOM nodes and storing mutable values (timers, previous state) that do not affect the visual UI.

#06
useReducer: Predictable State Transitions
MediumFree

useReducer in React manages complex state transitions by decoupling what happened (dispatching an action object) from how state updates (a pure reducer function). It is preferred over useState when state has interdependent fields or when passing dispatch down trees avoids callback re-creations.