Repository: react-hook-form/react-hook-form
File: src/useWatch.ts (TypeScript)

Code before:
  defaultValue: UnpackNestedValue<LiteralToPrimitive<TWatchFieldValue>>;
  control?: Control;
}): UnpackNestedValue<LiteralToPrimitive<TWatchFieldValue>>;
export function useWatch<TWatchFieldValues extends FieldValues>(props: {
  name: string[];
  defaultValue?: UnpackNestedValue<DeepPartial<TWatchFieldValues>>;
  control?: Control;
}): UnpackNestedValue<DeepPartial<TWatchFieldValues>>;
export function useWatch<TWatchFieldValues>({
  control,
  name,
  defaultValue,
}: UseWatchOptions): TWatchFieldValues {
  const methods = useFormContext();
  const {
    watchFieldsHookRef,
    watchFieldsHookRenderRef,
    watchInternal,
    defaultValuesRef,
  } = control || methods.control;
  const [value, setValue] = React.useState<unknown>(
    isUndefined(defaultValue)
      ? isString(name)
        ? get(defaultValuesRef.current, name)
        : isArray(name)
        ? name.map((inputName) => get(defaultValuesRef.current, inputName))
        : {}
      : defaultValue,
  );
  const idRef = React.useRef<string>();
  const defaultValueRef = React.useRef(defaultValue);
  const nameRef = React.useRef(name);

  const updateWatchValue = React.useCallback(
    () =>
      setValue(
        watchInternal(nameRef.current, defaultValueRef.current, idRef.current),
      ),
    [setValue, watchInternal, defaultValueRef, nameRef, idRef],
  );

  React.useEffect(() => {
    const id = (idRef.current = generateId());
    const watchFieldsHookRender = watchFieldsHookRenderRef.current;
    const watchFieldsHook = watchFieldsHookRef.current;
    watchFieldsHook[id] = new Set();
    watchFieldsHookRender[id] = updateWatchValue;
    watchInternal(nameRef.current, defaultValueRef.current, id);

    return () => {
      delete watchFieldsHook[id];

Review comment (suggestion):
I think `name.map` is not working correctly.

My suggestion is the following.

```ts
name.reduce((obj, inputName) => ({
  ...obj, 
  [inputName]: get(defaultValuesRef.current, inputName)
}), {})
```

Code after:
  defaultValue: UnpackNestedValue<LiteralToPrimitive<TWatchFieldValue>>;
  control?: Control;
}): UnpackNestedValue<LiteralToPrimitive<TWatchFieldValue>>;
export function useWatch<TWatchFieldValues extends FieldValues>(props: {
  name: string[];
  defaultValue?: UnpackNestedValue<DeepPartial<TWatchFieldValues>>;
  control?: Control;
}): UnpackNestedValue<DeepPartial<TWatchFieldValues>>;
export function useWatch<TWatchFieldValues>({
  control,
  name,
  defaultValue,
}: UseWatchOptions): TWatchFieldValues {
  const methods = useFormContext();
  const {
    watchFieldsHookRef,
    watchFieldsHookRenderRef,
    watchInternal,
    defaultValuesRef,
  } = control || methods.control;
  const [value, setValue] = React.useState<unknown>(
    isUndefined(defaultValue)
      ? isString(name)
        ? get(defaultValuesRef.current, name)
        : isArray(name)
        ? name.reduce(
            (previous, inputName) => ({
              ...previous,
              [inputName]: get(defaultValuesRef.current, inputName),
            }),
            {},
          )
        : defaultValuesRef.current
      : defaultValue,
  );
  const idRef = React.useRef<string>();
  const defaultValueRef = React.useRef(defaultValue);
  const nameRef = React.useRef(name);

  const updateWatchValue = React.useCallback(
    () =>
      setValue(
        watchInternal(nameRef.current, defaultValueRef.current, idRef.current),
      ),
    [setValue, watchInternal, defaultValueRef, nameRef, idRef],
  );

  React.useEffect(() => {
    const id = (idRef.current = generateId());
    const watchFieldsHookRender = watchFieldsHookRenderRef.current;
    const watchFieldsHook = watchFieldsHookRef.current;