Find: Uncontrolled to Controlled Switch
Find the Mistake Medium
Question
What is wrong with this input?
Code
const [value, setValue] = useState();
return <input value={value} onChange={e => setValue(e.target.value)} />;
Hint
What is the initial value of state?
Explanation
useState() initializes value to undefined, making the input uncontrolled initially. When the user types, it becomes controlled, causing a warning. The fix is: useState("") to initialize with an empty string.
Related Resources
Related Lessons
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.