Repository: react-hook-form/react-hook-form
File: src/controller.tsx (TypeScript)

Code before:
    unmountFieldsStateRef,
  } = control || methods.control;
  const isNotFieldArray = !isNameInFieldArray(fieldArrayNamesRef.current, name);
  const getInitialValue = () =>
    !isUndefined(get(unmountFieldsStateRef.current, name)) && isNotFieldArray
      ? unmountFieldsStateRef.current[name]
      : isUndefined(defaultValue)
      ? get(defaultValuesRef.current, name)
      : defaultValue;
  const [value, setInputStateValue] = React.useState(getInitialValue());
  const valueRef = React.useRef(value);
  const onFocusRef = React.useRef(onFocus);
  const isSubmitted = isSubmittedRef.current;

  if (process.env.NODE_ENV !== 'production') {
    if (isUndefined(value)) {
      console.warn(
        '📋 Controller `defaultValue` or useForm `defaultValues` is missing.',
      );
    }

    if (as && render) {
      console.warn('📋 Should use either `as` or `render` prop.');
    }

    if (!control) {
      console.warn('📋 Controller is missing `control` prop.');
    }
  }

  const shouldValidate = (isBlurEvent?: boolean) =>
    !skipValidation({
      isBlurEvent,
      isReValidateOnBlur,
      isReValidateOnChange,
      isSubmitted,
      ...mode,
    });

  const commonTask = ([event]: any[]) => {
    const data = getInputValue(event);
    setInputStateValue(data);
    valueRef.current = data;
    return data;
  };

  const registerField = React.useCallback(() => {
    if (process.env.NODE_ENV !== 'production' && !name) {
      return console.warn('📋 Field is missing `name` prop.');
    }


Review comment (suggestion):
```suggestion
    if (!control && !methods.control) {
```

Code after:
    unmountFieldsStateRef,
  } = control || methods.control;
  const isNotFieldArray = !isNameInFieldArray(fieldArrayNamesRef.current, name);
  const getInitialValue = () =>
    !isUndefined(get(unmountFieldsStateRef.current, name)) && isNotFieldArray
      ? unmountFieldsStateRef.current[name]
      : isUndefined(defaultValue)
      ? get(defaultValuesRef.current, name)
      : defaultValue;
  const [value, setInputStateValue] = React.useState(getInitialValue());
  const valueRef = React.useRef(value);
  const onFocusRef = React.useRef(onFocus);
  const isSubmitted = isSubmittedRef.current;

  if (process.env.NODE_ENV !== 'production') {
    if (isUndefined(value)) {
      console.warn(
        '📋 Controller `defaultValue` or useForm `defaultValues` is missing.',
      );
    }

    if (as && render) {
      console.warn('📋 Should use either `as` or `render` prop.');
    }

    if (!control && !methods.control) {
      console.warn('📋 Controller is missing `control` prop.');
    }
  }

  const shouldValidate = (isBlurEvent?: boolean) =>
    !skipValidation({
      isBlurEvent,
      isReValidateOnBlur,
      isReValidateOnChange,
      isSubmitted,
      ...mode,
    });

  const commonTask = ([event]: any[]) => {
    const data = getInputValue(event);
    setInputStateValue(data);
    valueRef.current = data;
    return data;
  };

  const registerField = React.useCallback(() => {
    if (process.env.NODE_ENV !== 'production' && !name) {
      return console.warn('📋 Field is missing `name` prop.');
    }