React warns that a form field has a value but no onChange handler
You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.Short answer
React renders a field as read-only when you give it value (or checked) and no onChange. Pick the one that matches your intent: use defaultValue for an initial value only, add an onChange that updates state to control the field, or add readOnly if the value should never change. Checkboxes use checked, not value.
Fix it fast
1Find out which cause you have
Find the input named in the console stack trace and look at its props. Does it have value or checked without onChange? That single fact picks the fix.
grep -rnE "value=\{|checked=\{" src/ | grep -v onChange2Match what you see, then jump to its fix
- 1
The text cannot be changed by typing, and the console shows the 'without an onChange handler' warningA controlled input with no handler to update the valueFix - 2
The value comes from props or an API and nothing in your code reads it back as the user editsYou only wanted an initial value, not a controlled fieldFix - 3
A value is shown on purpose, for example a generated code, and users should not edit itThe field is meant to be read-onlyFix - 4
The 'You provided a `checked` prop' warning, or a checkbox that never togglesA checkbox uses value instead of checked, or reads the wrong event fieldFix - 5
A component is changing an uncontrolled input to be controlledThe value starts as undefined or null and later becomes a stringFix
- 1
What does the error look like?
You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.You provided a `checked` prop to a form field without an `onChange` handler.A component is changing an uncontrolled input to be controlled
Cause 1 of 5
A controlled input with no handler to update the value
1Check
A field with a value prop is controlled: React forces it to show that value. If the state is not updated in onChange, every keystroke is reverted.
// the shape that triggers the warning
<input value={name} />2Fix
Add an onChange that writes the new text into the state the value comes from.
const [name, setName] = useState('');
<input value={name} onChange={e => setName(e.target.value)} />3Verify
Type in the field. The text appears and the warning is gone from the console.
# reload the page with the browser console open and type in the fieldConfirmed by react.dev
Cause 2 of 5
You only wanted an initial value, not a controlled field
1Check
If the code never needs the live text in state, a controlled input is more than you need. defaultValue sets the starting text and leaves the field editable.
grep -rn "value=" src/components/ProfileForm.jsx2Fix
Replace value with defaultValue (and checked with defaultChecked on a checkbox).
<input defaultValue={user.name} />
<input type="checkbox" defaultChecked={user.subscribed} />3Verify
The field shows the starting text and can be edited without a warning.
# reload the page and edit the fieldConfirmed by react.dev
Cause 3 of 5
The field is meant to be read-only
1Check
The warning says the field will render read-only. If that is what you want, say so with a prop, so React does not warn.
grep -rn "<input" src/ | grep -v onChange2Fix
Add readOnly to the input.
<input value={code} readOnly={true} />3Verify
The field still shows the value, cannot be edited, and logs no warning.
# reload the page and check the consoleConfirmed by react.dev
Cause 4 of 5
A checkbox uses value instead of checked, or reads the wrong event field
1Check
Checkboxes need checked or defaultChecked, and the handler must read e.target.checked, not e.target.value.
grep -rn 'type="checkbox"' src/2Fix
Control the checkbox with checked and read the boolean from the event.
<input
type="checkbox"
checked={accepted}
onChange={e => setAccepted(e.target.checked)}
/>3Verify
Click the box. It toggles and the console stays quiet.
# reload the page and click the checkboxConfirmed by react.dev
Cause 5 of 5
The value starts as undefined or null and later becomes a string
1Check
A value that comes from an API call is often undefined on the first render. React then treats the input as uncontrolled, and switches when the data arrives.
grep -rn "useState()" src/2Fix
Keep the value a string for the whole life of the input.
<input value={user.name ?? ''} onChange={e => setUser({ ...user, name: e.target.value })} />3Verify
Load the page with the network throttled. The warning no longer appears when the data arrives.
# reload the page with browser devtools network throttling onConfirmed by react.dev
How do I stop it coming back?
- Decide per field up front: controlled (value + onChange) or uncontrolled (defaultValue).
- Initialise form state with empty strings, not undefined.
- Search new code for inputs with value or checked and no onChange before merging.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Module not found for antd/dist/antd.less after upgrading to Ant Design 5
Module not found: Error: Can't resolve 'antd/dist/antd.less'
Ant Design 5 dropped Less and the bundled CSS file for CSS-in-JS, so antd/dist/antd.less no longer exists.
3 causes, each with a fixWeb apps
Astro Code component fails inside a React component
Astro components cannot be rendered directly via function call
Astro components such as Code only exist on the server and render static HTML.
2 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
How to catch and handle a 422 from Axios in a Redux thunk
action.error.message is 'Rejected' and action.payload is undefined
A 422 means the server read the request but cannot process its content, so repeating it unchanged fails again.
4 causes, each with a fixWeb apps
axios gets 429 Too Many Requests from a React app
429 (Too Many Requests)
A 429 comes from the server or an API gateway, not from axios: your client sent too many requests in a window.
4 causes, each with a fixWeb apps
Axios request is not cancelled when a React component unmounts
A cancelled request is logged as an error in the catch block
Axios cancels a request when you pass it an AbortSignal and later call abort() on its controller.
4 causes, each with a fix