question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inaccurate warning when value props is set without onChange.

See original GitHub issue

When you create an input component and set its value without providing an onChange handler, React will log this to the console:

"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. "

This isn’t entirely accurate however. For example in my app I rely on event bubbling so that I can set a single onChange on the form component, thereby saving my sanity preventing me from having to add an onChange to every. single. field. (There are a lot in the app I’m working on)

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:78
  • Comments:51 (12 by maintainers)

github_iconTop GitHub Comments

37reactions
sophiebitscommented, Mar 4, 2014

@Evernight What do you mean, it ignores the mouse events? This is a strange case and you can write onChange={function() {}} to suppress the warning.

32reactions
mor-giladcommented, Jun 14, 2016

What about adding: onChange={()=>{}} as an input attribute? It’s not perfect but it helps with the “warnings OCD” 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

You provided a `value` prop to a form field without an ...
Warning: Failed form propType: You provided a value prop to a form field without an onChange handler. This will render a read-only field....
Read more >
Controller | React Hook Form - Simple React forms validation
This simplifies integrating with external controlled components with non-standard prop names. Provides onChange , onBlur , name , ref and value to the...
Read more >
Deprecated prop for a React DOM element should not be used
React Warning: checkedLink prop on input is deprecated; set value and onChange instead. Was this documentation helpful? Analyze Your GitHub ...
Read more >
API Reference - Formik
Returns true if values are not deeply equal from initial values, false otherwise. dirty is a readonly computed property and should not be...
Read more >
API - React Select
Even when commonProps are not listed in the prop types below, a custom ... if the value entered in the field is invalid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found