The Mental Model of React Hooks
React hooks allow functional components to subscribe to state and lifecycle events. However, misunderstanding closures and dependency arrays frequently leads to stale state bugs and performance bottlenecks.
1. The Truth About useEffect
useEffect is not a component lifecycle method; it is a synchronization mechanism between React state and external systems (DOM APIs, WebSockets, network timers).
2. When to Reach for useMemo and useCallback
Overusing memoization adds memory overhead without tangible performance gains. Use useMemo only when doing computationally heavy operations (filtering 10,000 items) or preserving referential identity for child component dependencies.
3. Custom Hook Extraction
Keep UI components declarative by extracting business logic, fetching routines, and event listeners into reusable custom hooks like useDebounce and useWindowDimensions.

