Skip to content

Commit

Permalink
Fix Infinite render on country code chnage
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidSumra committed Dec 9, 2024
1 parent f87a2a4 commit 23220f3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Form/FormFields/PhoneNumberFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const PhoneNumberFormField = React.forwardRef<HTMLInputElement, Props>(
};

useEffect(() => {
console.log(field.value);
if (field.value && field.value.length > 0) {
if (field.value.startsWith("1800")) {
setCountry({ flag: "📞", name: "Support", code: "1800" });
Expand All @@ -105,7 +106,7 @@ const PhoneNumberFormField = React.forwardRef<HTMLInputElement, Props>(
}
setCountry(phoneCodes[getCountryCode(field.value)!]);
}
}, [setValue]);
}, [field.value]);

return (
<FormField
Expand Down

0 comments on commit 23220f3

Please sign in to comment.