diff --git a/src/components/ui/phone-input.jsx b/src/components/ui/phone-input.jsx index 8ce2e03..43c2098 100644 --- a/src/components/ui/phone-input.jsx +++ b/src/components/ui/phone-input.jsx @@ -64,6 +64,8 @@ const CountrySelect = ({ const [searchValue, setSearchValue] = React.useState("") const [isOpen, setIsOpen] = React.useState(false) + const handleSelectComplete = React.useCallback(() => setIsOpen(false), []) + return ( setIsOpen(false)} + onSelectComplete={handleSelectComplete} /> ) : null, )} @@ -136,23 +138,27 @@ const CountrySelect = ({ ) } -const CountrySelectOption = ({ +const CountrySelectOption = React.memo(function CountrySelectOption({ country, countryName, selectedCountry, onChange, onSelectComplete, -}) => { +}) { const handleSelect = () => { onChange(country) onSelectComplete() } return ( - +
- {countryName} + {countryName}
{`+${RPNInput.getCountryCallingCode(country)}`} @@ -162,9 +168,9 @@ const CountrySelectOption = ({
) -} +}) -const FlagComponent = ({ country, countryName }) => { +const FlagComponent = React.memo(function FlagComponent({ country, countryName }) { const Flag = flags[country] return ( @@ -172,6 +178,6 @@ const FlagComponent = ({ country, countryName }) => { {Flag && } ) -} +}) export { PhoneInput }