Docs

React — Interview Questions & Mental Models

Code reading angle — stale deps


  • When shown a useEffect with a dependency omitted from the array, ask: is that value stale?
  • If b is used inside the effect but omitted from deps, yes — fix deps or document intentional omission with lint disable + comment.
  • Study order for a sprint: hooks rules → useEffect deps & cleanup → batching → memo/useCallback when → Context pitfalls → error boundaries → Profiler mindset.
1useEffect(() => { 2 doSomething(a, b) 3}, [a]) // b is stale if omitted