What is Controlled Component?
A Controlled Component is one that takes its current value through state and notifies changes through callbacks like onChange
.
For example below, I log the name when it is submitted, with controlled component:
See the Pen pVBwwa by Bunlong (@Bunlong) on CodePen.
<input>
form element takes its current value through this.state.value
. handleChange
runs on every keystroke to update this.state.value
, the displayed value will update as the user types.