What 'Single Source of Truth' Means
You'll learn why React state becomes the one authoritative place that defines input values.
The Core Idea
Before controlled components, an input field had two places storing its value:
- The DOM element itself (the browser's internal state)
- Potentially your JavaScript variables
This created confusion: which one is "correct"? With controlled components, React state becomes the single source of truth — the only authoritative place that defines what the input displays. The DOM simply reflects that state.
The Old Way vs The React Way
Without controlled components:
- User types → DOM updates itself
- JavaScript has no idea what changed
- Two separate "truths" exist
With controlled components:
- User types →
onChangefires → updates React state - React re-renders → state flows back to
valueprop → DOM reflects state - Only one truth: the state variable
The Analogy
Think of a scoreboard at a sports game. The single source of truth is the official scorekeeper's record. The scoreboard displays that record. You wouldn't let spectators write directly on the scoreboard — they'd tell the scorekeeper, who updates the official record, which then updates the display.
React state = official record
Input's value prop = scoreboard display
onChange = the communication channel
Why This Matters
When state is the single source of truth, you always know the current value. You can validate it, transform it, clear it programmatically, or sync it across components. There's no DOM state to "get out of sync" with your JavaScript logic.
Key Takeaway: Single source of truth means React state is the authoritative value, and the DOM always reflects it — never the other way around.