Skip to content

Commit

Permalink
unregister to remove residual state
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Jan 7, 2024
1 parent c2134a7 commit d0fab3f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/Admin/Charity/Banking/V2Form/Requirements/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function Form({
onSubmit={handleSubmit(
async (fv) => {
const { accountHolderName, ...details } = fv;

const res = await createRecipient({
accountHolderName,
currency,
Expand All @@ -89,7 +90,7 @@ export default function Form({
}
//only focus on first error
const [name] = content.errors[0].arguments;
setFocus(name);
return setFocus(name);
}
}
},
Expand All @@ -98,7 +99,6 @@ export default function Form({
className="grid gap-5 text-gray-d2"
>
{fields.map((f) => {
console.log(f);
const labelRequired = f.required ? true : undefined;
if (f.type === "select") {
return (
Expand All @@ -110,6 +110,7 @@ export default function Form({
{...register(f.key, {
required: f.required ? "required" : false,
onChange: f.refreshRequirementsOnChange ? refresh : undefined,
shouldUnregister: true,
})}
aria-required={f.required}
id={f.key}
Expand Down Expand Up @@ -153,6 +154,7 @@ export default function Form({
onChange: f.refreshRequirementsOnChange
? refresh
: undefined,
shouldUnregister: true,
})}
/>
<label
Expand Down Expand Up @@ -214,6 +216,7 @@ export default function Form({
: undefined,
//onBlur only as text input changes rapidly
onBlur: f.refreshRequirementsOnChange ? refresh : undefined,
shouldUnregister: true,
})}
/>
<ErrorMessage
Expand Down Expand Up @@ -253,6 +256,7 @@ export default function Form({
: undefined,
//onBlur only as text input changes rapidly
onBlur: f.refreshRequirementsOnChange ? refresh : undefined,
shouldUnregister: true,
})}
/>
<ErrorMessage
Expand Down

0 comments on commit d0fab3f

Please sign in to comment.