CPCODELAB
React

Thinking in React — Component Architecture

12 min read

The React Mental Model

React's official "Thinking in React" guide describes a five-step process for building an app from a design mockup. Internalising this process is what separates developers who fight React from those who flow with it.

  1. Break the UI into a component hierarchy — draw boxes around each visual region and name them.
  2. Build a static version first — no state, no interactivity; just props flowing down.
  3. Identify the minimal representation of state — ask: can it be derived? If so, don't store it.
  4. Identify where state should live — find the common ancestor of all components that need it.
  5. Add inverse data flow — pass setters down so children can update ancestor state.

Practical architecture tips

  • Keep UI components pure — same props always produce same JSX.
  • Put data-fetching and side effects in container components or custom hooks.
  • Derive values from state at render time rather than syncing separate state variables.
  • Name components and props after what they are, not how they're implemented.

When you're stuck deciding where state should live, start by putting it as low in the tree as possible. Lift it up only when a second component needs access. This keeps components independent and easy to test.

Ready to test yourself?
Practice React— quiz & coding exercises