DT
โ†
Back to Blog
ReactNovember 22, 2025 โ€ข 15 min read

React Hooks:
The Mental Models You're Missing

Hooks fundamentally changed how we write React components. But too many developers are coding with superstition. Let's build the mental models.

๐Ÿ“ Show Notes & Ideasโ–ผ
๐Ÿ“
Notes & Ideas

The "Senior Dev" Cheat Sheet

  • 1.The Golden Rule of Order. React tracks hooks using a simple array index (0, 1, 2). It does not know names. Rule: Never put a hook inside an if statement, loop, or nested function.
  • 2.The useState Trap. State variables inside functions (like setTimeout) are stale "photographs" of the past. Rule: If your update depends on the previous value, always use the functional update: setCount(prev => prev + 1).
  • 3.The useEffect Mindset. useEffect is not componentDidMount. It is a synchronization engine. Rule: Your effect must handle being run twice (Strict Mode). If it breaks, your cleanup logic is missing.
  • 4.The Performance Lie. Wrapping functions in useCallback does not make your app faster. It adds memory overhead. Rule: Only use useCallback if the child component receiving the function is wrapped in React.memo. Otherwise, delete it.
  • 5.The Context Warning. Context is not a state manager; it is a dependency injection tool. Rule: When Context changes, every component consuming it re-renders. Use it for Theme/Auth only.
0

ยฉ 2026 DTHOMPSONDEV. All rights reserved.

RRSS Feed