MCPcopy Create free account
hub / github.com/react-hook-form/react-hook-form / watch

Function watch

src/logic/createFormControl.ts:1144–1168  ·  view source on GitHub ↗
(
    name?:
      | FieldPath<TFieldValues>
      | ReadonlyArray<FieldPath<TFieldValues>>
      | WatchObserver<TFieldValues>,
    defaultValue?: DeepPartial<TFieldValues>,
  )

Source from the content-addressed store, hash-verified

1142 };
1143
1144 const watch: UseFormWatch<TFieldValues> = (
1145 name?:
1146 | FieldPath<TFieldValues>
1147 | ReadonlyArray<FieldPath<TFieldValues>>
1148 | WatchObserver<TFieldValues>,
1149 defaultValue?: DeepPartial<TFieldValues>,
1150 ) =>
1151 isFunction(name)
1152 ? _subjects.state.subscribe({
1153 next: (payload) =>
1154 'values' in payload &&
1155 name(
1156 payload.values || _getWatch(undefined, defaultValue),
1157 payload as {
1158 name?: FieldPath<TFieldValues>;
1159 type?: EventType;
1160 value?: unknown;
1161 },
1162 ),
1163 })
1164 : _getWatch(
1165 name as InternalFieldName | InternalFieldName[],
1166 defaultValue,
1167 true,
1168 );
1169
1170 const _subscribe: FromSubscribe<TFieldValues> = (props) =>
1171 _subjects.state.subscribe({

Callers 15

AppFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
ComponentFunction · 0.85
ComponentFunction · 0.85

Calls 1

_getWatchFunction · 0.85

Tested by 15

AppFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
ComponentFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
ComponentFunction · 0.68
ComponentFunction · 0.68