mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Do not warn when a controlled input has onInput handler. (#18189)
`onInput` behaves the same as `onChange` for controlled inputs as far as I know, so React should not print the following warning when `onInput` is present. > Failed prop type: 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 commit is contained in:
@@ -115,6 +115,10 @@ describe('ReactDOMInput', () => {
|
||||
ReactDOM.render(<input type="checkbox" checked={undefined} />, container);
|
||||
});
|
||||
|
||||
it('should not warn with value and onInput handler', () => {
|
||||
ReactDOM.render(<input value="..." onInput={() => {}} />, container);
|
||||
});
|
||||
|
||||
it('should properly control a value even if no event listener exists', () => {
|
||||
let node;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ if (__DEV__) {
|
||||
if (
|
||||
hasReadOnlyValue[props.type] ||
|
||||
props.onChange ||
|
||||
props.onInput ||
|
||||
props.readOnly ||
|
||||
props.disabled ||
|
||||
props[propName] == null ||
|
||||
|
||||
Reference in New Issue
Block a user