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

Function resetDefaultValues

src/logic/createFormControl.ts:1868–1888  ·  view source on GitHub ↗
(
    values,
    options = {},
  )

Source from the content-addressed store, hash-verified

1866 });
1867
1868 const resetDefaultValues: UseFormResetDefaultValues<TFieldValues> = (
1869 values,
1870 options = {},
1871 ) => {
1872 _defaultValues = cloneObject(values) as Partial<typeof _defaultValues>;
1873
1874 if (!options.keepDirty) {
1875 const newDirtyFields = getDirtyFields(_defaultValues, _formValues);
1876 _formState.dirtyFields = newDirtyFields as typeof _formState.dirtyFields;
1877 _formState.isDirty = !isEmptyObject(newDirtyFields);
1878 }
1879
1880 if (!options.keepIsValid) {
1881 _setValid();
1882 }
1883
1884 _subjects.state.next({
1885 ..._formState,
1886 defaultValues: _defaultValues as FormState<TFieldValues>['defaultValues'],
1887 });
1888 };
1889
1890 const methods = {
1891 control: {

Callers

nothing calls this directly

Calls 3

cloneObjectFunction · 0.85
getDirtyFieldsFunction · 0.85
_setValidFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…