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:
Utkarsh Kukreti
2020-04-02 00:28:07 +05:30
committed by GitHub
parent 7516bdfce3
commit 5200547100
2 changed files with 5 additions and 0 deletions
@@ -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 ||