Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Aug 17, 2020
1 parent a7261d6 commit 6f74d9c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,17 @@ export function useForm<T extends FormData = FormData>(
setSubmitting(true);

const isFormValid = await validateAllFields();
const formData = isFormValid ? getFormData() : null;
const formData = isFormValid ? getFormData() : ({} as T);

if (onSubmit) {
await onSubmit(formData ?? ({} as T), isFormValid!);
await onSubmit(formData, isFormValid!);
}

if (isUnmounted.current === false) {
setSubmitting(false);
}

return { data: formData ?? ({} as T), isValid: isFormValid! };
return { data: formData, isValid: isFormValid! };
},
[validateAllFields, getFormData, onSubmit]
);
Expand Down

0 comments on commit 6f74d9c

Please sign in to comment.