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

Why Controlled Components Re-render on Every Change

Each keystroke updates state, triggers a re-render, and keeps the input synchronized—this is by design, not a bug.

Why Controlled Components Re-render on Every Change

You'll learn why controlled inputs trigger a re-render on every keystroke, and why that's actually the correct behavior.

When you type a single character into a controlled input, here's what happens:

  1. The onChange handler fires
  2. You call setState with the new value
  3. React schedules a re-render
  4. The component re-renders with updated state
  5. The input receives the new value prop

This happens for every single keystroke. That might sound inefficient, but it's the entire point of controlled components—React needs to stay in sync with the DOM.

The Synchronization Contract

A controlled input's value comes from React state, not the DOM. When you type, the browser tries to update the input, but React overrides it during the next render. This two-way flow keeps React as the "single source of truth."

Think of it like a puppet: the input (puppet) can't move on its own—it only displays what the puppeteer (React state) tells it to. Every time you pull the strings (setState), the puppet updates its position (re-render).

Why This Isn't a Performance Problem

React's rendering is highly optimized. A single component re-render is typically sub-millisecond. The actual DOM updates are minimal because React only changes the input's value attribute if it differs from before.

This design enables powerful features:

  • Validation: You control exactly what appears in the input
  • Formatting: Transform values as users type
  • Derived state: Other components react instantly to input changes

Not a Bug—It's the Feature

If controlled inputs didn't re-render on every change, they wouldn't be controlled—they'd be uncontrolled. The re-renders are what keep your UI predictable and your data flow unidirectional.

Key Takeaway: Controlled components re-render on every keystroke by design—this synchronization between state and the DOM is what makes them "controlled" and enables validation, formatting, and real-time updates.