Course contentsShow
← React
Lesson 450 of 2,39613. Controlled ComponentsFree lesson

What Makes a Component 'Controlled'

A controlled component's value is driven by React state via the value prop, making React the single source of truth.

What Makes a Component 'Controlled'

You'll learn: What distinguishes a controlled component from an uncontrolled one, and why it matters for forms and interactive elements.

The Core Idea

A controlled component is one where React state is the single source of truth for the component's current value. Instead of letting the DOM element (like an <input>) manage its own state internally, you explicitly set its value via the value prop and update it through React's useState.

Think of it like a puppet show: in a controlled component, React holds all the strings. The input field displays whatever React state tells it to display, and every keystroke flows through React state before updating the UI.

The Controlled Pattern

Here's what makes a component controlled:

  1. The value prop is set from React state — the input displays value={stateVariable}
  2. An onChange handler updates that state — every user interaction triggers setState
  3. React re-renders, feeding the new value back — the loop completes
const [email, setEmail] = useState('');

<input 
  value={email}           // ← Controlled by React state
  onChange={(e) => setEmail(e.target.value)}
/>

Without the value prop, the input would be uncontrolled — the DOM element would manage its own internal state, and React would just be an observer.

Why Control Matters

When you control an input, you can:

  • Validate and transform input as the user types
  • Sync the same value across multiple components
  • Reset forms by updating state
  • Know the exact value at any moment without querying the DOM

Key Takeaway: A controlled component's value is driven by React state via the value prop, making React the single source of truth instead of the DOM.