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

Function clearErrors

src/logic/createFormControl.ts:1248–1265  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

1246 });
1247
1248 const clearErrors: UseFormClearErrors<TFieldValues> = (name) => {
1249 const names = name ? convertToArrayPayload(name) : undefined;
1250
1251 names?.forEach((inputName) => unset(_formState.errors, inputName));
1252
1253 if (names) {
1254 names.forEach((inputName) => {
1255 _subjects.state.next({
1256 name: inputName,
1257 errors: _formState.errors,
1258 });
1259 });
1260 } else {
1261 _subjects.state.next({
1262 errors: {},
1263 });
1264 }
1265 };
1266
1267 const setError: UseFormSetError<TFieldValues> = (name, error, options) => {
1268 const ref = (get(_fields, name, { _f: {} })._f || {}).ref;

Callers 9

validateFormFunction · 0.85
AppFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
ValidateFieldCriteriaFunction · 0.85
SetErrorFunction · 0.85
appendQuestionFunction · 0.85
appendQuestionFunction · 0.85

Calls 1

unsetFunction · 0.85

Tested by 4

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…