Controlled Inputs
A controlled input shows a value from state and updates it in onChange. State is the single source of truth.
Example
function NameBox() {
const [name, setName] = useState('');
return (
<input value={name} onChange={(e) => setName(e.target.value)} />
);
}Exercise
Read the typed text.
e.target.Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.