Add comments and optimized code

This commit is contained in:
2023-10-30 09:34:14 +07:00
parent 367b24f4fa
commit 04469af993
6 changed files with 22 additions and 12 deletions
+3 -1
View File
@@ -37,6 +37,8 @@ const useForm = (
setInitialErrorState(initialValue);
setDisable(true);
// If initial value true, setValues again from stateSchema
// and enabled button
if (initialValue) {
setValues({});
setValues(getPropValues(stateSchema, VALUE));
@@ -83,7 +85,7 @@ const useForm = (
Object.keys(errors).map((name) =>
setErrors((prevState) => ({
...prevState,
[name]: !initialValue
[name]: !initialValue // Skip error when initialValue have values
? validateFormFields(name, values[name] as string)
: '',
})),