react-phone-number-input icon indicating copy to clipboard operation
react-phone-number-input copied to clipboard

Can i change the flag to the country code?

Open adityanegara opened this issue 3 years ago • 2 comments

For example if i pick 'Indonesia' can the selected options render '+62' not Indonesia Flag?

adityanegara avatar Jan 06 '22 03:01 adityanegara

What?

catamphetamine avatar Jan 06 '22 12:01 catamphetamine

We do the same thing (because the flag icons are ugly):

image

We generate an object with all the country calling codes and pass it to the flags attribute:

const flagOptions = useMemo(() => Object.fromEntries(getCountries().map((country: Country) => (
    [country, () => <>+{getCountryCallingCode(country)}</>]
))), []);
flags={flagOptions}

michael5r avatar Jan 09 '24 16:01 michael5r