React·Beginner·Coding·1 min read
What determines whether an input is controlled or uncontrolled?
Short interview answer
Whether its value prop is driven by React state (controlled, React is the source of truth) or whether the DOM manages the input's value internally with React only reading it on demand, typically via a ref (uncontrolled).
Example
// Controlled — React owns the value<input value={name} onChange={(e) => setName(e.target.value)} />
// Uncontrolled — the DOM owns it; read on demand<input ref={nameRef} defaultValue="" />Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.