1. /**
    
  2.  * Copyright (c) Meta Platforms, Inc. and affiliates.
    
  3.  *
    
  4.  * This source code is licensed under the MIT license found in the
    
  5.  * LICENSE file in the root directory of this source tree.
    
  6.  *
    
  7.  * @noflow
    
  8.  */
    
  9. 
    
  10. const hasReadOnlyValue = {
    
  11.   button: true,
    
  12.   checkbox: true,
    
  13.   image: true,
    
  14.   hidden: true,
    
  15.   radio: true,
    
  16.   reset: true,
    
  17.   submit: true,
    
  18. };
    
  19. 
    
  20. export function checkControlledValueProps(
    
  21.   tagName: string,
    
  22.   props: Object,
    
  23. ): void {
    
  24.   if (__DEV__) {
    
  25.     if (
    
  26.       !(
    
  27.         hasReadOnlyValue[props.type] ||
    
  28.         props.onChange ||
    
  29.         props.onInput ||
    
  30.         props.readOnly ||
    
  31.         props.disabled ||
    
  32.         props.value == null
    
  33.       )
    
  34.     ) {
    
  35.       console.error(
    
  36.         'You provided a `value` prop to a form field without an ' +
    
  37.           '`onChange` handler. This will render a read-only field. If ' +
    
  38.           'the field should be mutable use `defaultValue`. Otherwise, ' +
    
  39.           'set either `onChange` or `readOnly`.',
    
  40.       );
    
  41.     }
    
  42. 
    
  43.     if (
    
  44.       !(
    
  45.         props.onChange ||
    
  46.         props.readOnly ||
    
  47.         props.disabled ||
    
  48.         props.checked == null
    
  49.       )
    
  50.     ) {
    
  51.       console.error(
    
  52.         'You provided a `checked` prop to a form field without an ' +
    
  53.           '`onChange` handler. This will render a read-only field. If ' +
    
  54.           'the field should be mutable use `defaultChecked`. Otherwise, ' +
    
  55.           'set either `onChange` or `readOnly`.',
    
  56.       );
    
  57.     }
    
  58.   }
    
  59. }