Manage a form object with useState.
Section: Forms and Event Patterns
Controlled form state
tsx
tsx
const [form, setForm] = useState({ email: '', password: '' });
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setForm(prev => ({ ...prev, [name]: value }));
};Explanation
A standard controlled form pattern for smaller forms.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Forms and Event Patterns
Complex form with useReducer
Use a reducer when form behavior becomes more complex.
Custom hook with options object
Prefer options objects for extensible APIs.