React · Frontend system thinking
What is the difference between controlled and uncontrolled components?
Short answer
A controlled input gets its value from React state and changes through an event handler. An uncontrolled input keeps its own DOM state and is read with a ref or FormData.
The distinction is who owns the input value. Controlled inputs make React the source of truth, which is useful for validation, formatting and conditional UI. Uncontrolled inputs are closer to plain HTML and can be simpler for large forms.
function Controlled() {
const [name, setName] = useState("");
return (
<input
value={name}
onChange={(event) => setName(event.target.value)}
/>
);
}
function Uncontrolled() {
const inputRef = useRef(null);
return <input ref={inputRef} defaultValue="Asha" />;
}Trade-offs
- Controlled: predictable value, easy validation and formatting, more re-renders
- Uncontrolled: less code for simple forms, value lives in the DOM, read on submit
defaultValuesets the initial value for an uncontrolled input- React 19 form actions can read submitted values with
FormData
Do not mix value and defaultValue on the same input. Choose one ownership model. If you need a controlled input, always provide onChange or the field becomes read-only.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1When would you choose an uncontrolled input?
- 2Why does an input become read-only when you pass `value` without `onChange`?
- 3How do you read an uncontrolled form on submit?
- 4Why are file inputs uncontrolled?
Say it in the interview
A controlled input takes its value from React state and updates through onChange, so React is the source of truth. An uncontrolled input keeps its value in the DOM and I read it with a ref or FormData on submit. Controlled is better for validation and dependent UI; uncontrolled is simpler for basic forms and file inputs. I never mix value and defaultValue on the same field.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live React mock interview and get scored feedback on depth, clarity and confidence.