MCPcopy
hub / github.com/react-hook-form/react-hook-form / setError

Function setError

src/logic/createFormControl.ts:1267–1286  ·  view source on GitHub ↗
(name, error, options)

Source from the content-addressed store, hash-verified

1265 };
1266
1267 const setError: UseFormSetError<TFieldValues> = (name, error, options) => {
1268 const ref = (get(_fields, name, { _f: {} })._f || {}).ref;
1269 const currentError = get(_formState.errors, name) || {};
1270
1271 const { ref: currentRef, message, type, ...restOfErrorTree } = currentError;
1272
1273 set(_formState.errors, name, {
1274 ...restOfErrorTree,
1275 ...error,
1276 ref,
1277 });
1278
1279 _subjects.state.next({
1280 name,
1281 errors: _formState.errors,
1282 isValid: false,
1283 });
1284
1285 options && options.shouldFocus && ref && ref.focus && ref.focus();
1286 };
1287
1288 const watch: UseFormWatch<TFieldValues> = (
1289 name?:

Callers 15

validateFormFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
FormFunction · 0.85
AppFunction · 0.85
AppFunction · 0.85
AppFunction · 0.85
AppFunction · 0.85
MyFormFunction · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
ValidateFieldCriteriaFunction · 0.85

Calls

no outgoing calls

Tested by 10

AppFunction · 0.68
ComponentFunction · 0.68
FormFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68
MyFormFunction · 0.68
ComponentFunction · 0.68
AppFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…