Skip to content

Commit

Permalink
fix form clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
ptbarnum4 committed Jul 20, 2023
1 parent d44ec40 commit 0c1404b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Form/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,16 @@ const useForm = <T extends Record<keyof T, T[keyof T]> = {}>() => {
/** Clear/reset form values */
clear: () => {
setValues({} as T);
setSelectValues({} as T);
setCheckboxValues({} as T);
setCheckboxGroupValues({} as T);
setValidation({});
setShowErrors(false);

const clearedSelectValues = Object.keys(selectValues).reduce((acc, key) => {
acc[key] = { value: '', name: '' };
return acc;
}, {} as ISelectValues);
setSelectValues(clearedSelectValues);
},
};
};
Expand Down

0 comments on commit 0c1404b

Please sign in to comment.