Tsallaka zuwa abun ciki
Justice Tech School

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

What makes an input controlled?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.