@samitouri / QOS-React-2 / commits / 5200547100

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

Utkarsh Kukreti committed Apr 2, 2020 at 00:28 UTC 5200547100cb8505eb293f84da53762b7c482fc2
2 files changed +5
packages/react-dom/src/__tests__/ReactDOMInput-test.js
+4
@@ -115,6 +115,10 @@ describe('ReactDOMInput', () => {
115 ReactDOM.render(<input type="checkbox" checked={undefined} />, container);
116 });
117
118 + it('should not warn with value and onInput handler', () => {
119 + ReactDOM.render(<input value="..." onInput={() => {}} />, container);
120 + });
121 +
122 it('should properly control a value even if no event listener exists', () => {
123 let node;
124
packages/react-dom/src/shared/ReactControlledValuePropTypes.js
+1
@@ -33,6 +33,7 @@ if (__DEV__) {
33 if (
34 hasReadOnlyValue[props.type] ||
35 props.onChange ||
36 + props.onInput ||
37 props.readOnly ||
38 props.disabled ||
39 props[propName] == null ||