Skip to content
React·Intermediate·Coding·1 min read

What warning does React give when an input switches between controlled and uncontrolled?

Short interview answer

It warns that a component is changing an uncontrolled input to be controlled, or vice versa, typically because the value prop starts as undefined and later becomes a defined string, or the reverse — React expects one model to be chosen and kept consistent.

Example

JSX
// value is undefined on first render -> becomes a string later => warning<input value={user?.name} onChange={onChange} />// Fix: <input value={user?.name ?? ''} ... />

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Controlled vs. uncontrolled components

Related questions