Every Keystroke Triggers a Re-render
What you'll learn: Why typing a single character in a controlled input causes your entire component to re-render—and why that's exactly what's supposed to happen.
The Per-Character Re-render Reality
When you use a controlled input, every single keystroke triggers a complete component re-render. Type "hello"? That's five re-renders. Not one when you're done typing—five individual render cycles, one per character.
Here's the flow for each keystroke:
- User types "h"
onChangefires- You call
setState("h") - React schedules a re-render
- Component re-renders with
value="h" - DOM updates to show "h"
Then the same cycle repeats for "e", then "l", then "l", then "o".
Why This Happens
Remember the setState → Re-render → DOM Update Flow (concept 467)? Controlled components rely on this exact mechanism. Your state is the single source of truth, so when state changes, the component must re-render to display the new value.
The input's value prop doesn't magically update itself—React needs to re-render and pass the new value down through the prop.
This Is Not a Bug
You might worry: "Five re-renders for a five-letter word? That sounds wasteful!" But React's render phase is optimized for speed, and batching (concept 418-419) often groups rapid updates together. The re-render happens, but it's typically imperceptible to users.
This behavior enables all the benefits you've learned: real-time validation, formatting, conditional rendering, and programmatic control.
Key Takeaway: In controlled components, every keystroke causes a re-render because React must update the component with new state to keep the input's value prop in sync—this is the expected, designed behavior that powers real-time control over inputs.