Full answer
A form field always has a current value. The question is who owns it.
In a controlled component, state in React owns the value. You pass value={name} and an onChange that calls the setter. The input shows only what state says, so you can validate, format or block characters on every keystroke, and other parts of the screen can read the same state.
In an uncontrolled component, the browser DOM owns the value. You give an optional starting value with defaultValue and read the current value later through a ref, or through new FormData(form) on submit. React does not re-render on each keystroke, which keeps large forms cheap.
Choose by need. Live validation, a character counter, enabling a button as the user types, or dependent fields call for controlled inputs. A sign-up form that is read once on submit works well uncontrolled. An <input type="file"> is always uncontrolled because its value can only be set by the user.
React warns when a field changes between uncontrolled and controlled, which happens if value starts as undefined and later becomes a string. Start state with an empty string, not undefined or null.
In React 19 a form can also use an action: <form action={saveAction}>. React passes the FormData to the function, so fields can stay uncontrolled. After a successful action React resets uncontrolled fields.
import { useState } from 'react';
export default function Controlled() {
const [email, setEmail] = useState(''); // never undefined
return <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} />;
}import { useRef, useState } from 'react';
function ControlledName() {
const [name, setName] = useState('');
return (
<label>
Controlled name
<input value={name} onChange={(e) => setName(e.target.value)} />
<span> {name.length} characters</span>
</label>
);
}
function UncontrolledName() {
const inputRef = useRef(null);
const [saved, setSaved] = useState('');
function handleSubmit(event) {
event.preventDefault();
setSaved(inputRef.current.value);
}
return (
<form onSubmit={handleSubmit}>
<label>
Uncontrolled name
<input defaultValue="" ref={inputRef} />
</label>
<button type="submit">Save</button>
<p>Saved: {saved}</p>
</form>
);
}
export default function App() {
return (
<>
<ControlledName />
<UncontrolledName />
</>
);
}The controlled field updates a character counter on every keystroke. The uncontrolled field is read only when the form is submitted. The check typed a name into each field and then pressed Save. Result: <label>Controlled name<input value="Asha"><span> 4 characters</span></label><form><label>Uncontrolled name<input value=""></label><button type="submit">Save</button><p>Saved: Asha2</p></form>
Key points
- Controlled: value comes from state and changes go through onChange.
- Uncontrolled: the DOM holds the value. Read it with a ref or FormData, and set a start value with defaultValue.
- Use controlled inputs for live validation and dependent UI, uncontrolled for simple submit-only forms.
- Initial state of a controlled input must be a string, not undefined.
- File inputs are always uncontrolled.
Common mistakes
- Setting value without onChange, which makes the input read-only and triggers a warning.
- Starting a controlled field with undefined or null, then switching to a string.
- Using defaultValue and expecting it to update when state changes.
- Reading event.target.value after an await, instead of copying it first.
Follow-ups
- What is the cost of making a large form fully controlled, and how can you reduce it?
- How do React 19 form actions change how you read form values?
- How would you reset a controlled form and an uncontrolled form?
Tips
- Define "who owns the value" in your first sentence. It frames the whole answer.
- Give one case for each style. Interviewers dislike "always controlled".
- Mention the file input as the standard uncontrolled example.