From 7e6a3ec1ff02f22095737447c462842786df89a0 Mon Sep 17 00:00:00 2001 From: amitbadala Date: Fri, 27 Oct 2023 19:22:59 +0530 Subject: [PATCH] Initialize fieldstates at the start --- lib/build/emailpassword-shared7.js | 6 +++++- lib/ts/recipe/emailpassword/components/library/formBase.tsx | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/build/emailpassword-shared7.js b/lib/build/emailpassword-shared7.js index b2430ed7c..aec97b722 100644 --- a/lib/build/emailpassword-shared7.js +++ b/lib/build/emailpassword-shared7.js @@ -471,7 +471,11 @@ var FormBase = function (props) { }, [unmounting] ); - var _a = React.useState([]), + var _a = React.useState( + props.formFields.map(function (f) { + return { id: f.id, value: "" }; + }) + ), fieldStates = _a[0], setFieldStates = _a[1]; var _b = React.useState(false), diff --git a/lib/ts/recipe/emailpassword/components/library/formBase.tsx b/lib/ts/recipe/emailpassword/components/library/formBase.tsx index 14d540e11..7ea1d2510 100644 --- a/lib/ts/recipe/emailpassword/components/library/formBase.tsx +++ b/lib/ts/recipe/emailpassword/components/library/formBase.tsx @@ -68,7 +68,9 @@ export const FormBase: React.FC> = (props) => { }; }, [unmounting]); - const [fieldStates, setFieldStates] = useState([]); + const [fieldStates, setFieldStates] = useState( + props.formFields.map((f) => ({ id: f.id, value: "" })) + ); const [isLoading, setIsLoading] = useState(false); useEffect(() => {