Skip to content

Commit 31b4775

Browse files
committed
refactor: minor reset values simplification
1 parent 90b61fc commit 31b4775

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

packages/vee-validate/src/useForm.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,16 +495,10 @@ export function useForm<TValues extends Record<string, any> = Record<string, any
495495
// Reset all field states first
496496
mutateAllFields(f => f.resetField());
497497

498-
// set initial values if provided
499-
if (state?.values) {
500-
setInitialValues(state.values);
501-
setValues(state?.values);
502-
} else {
503-
// clean up the initial values back to the original
504-
setInitialValues(originalInitialValues.value);
505-
// otherwise clean the current values
506-
setValues(originalInitialValues.value);
507-
}
498+
// reset values
499+
const newValues = state?.values ? state.values : originalInitialValues.value;
500+
setInitialValues(newValues);
501+
setValues(newValues);
508502

509503
if (state?.touched) {
510504
setTouched(state.touched);

0 commit comments

Comments
 (0)