React · Junior · Question 21 of 75
React warns: "You provided a value prop to a form field without an onChange handler". What happened?
- ✓Correct answer: The field became read-only:
valueis set butonChangeisn't - 2A controlled field can't be used inside a
<form>tag - 3The
valuemust be a number, but a string was passed
Explanation
If you set value without onChange, React resets the field to that value on every render, and the user can't type. Fixes: add onChange, use defaultValue for an uncontrolled field, or set readOnly explicitly.