catamphetamine / react-phone-number-input

React component for international phone number input
http://catamphetamine.gitlab.io/react-phone-number-input/
MIT License
924 stars 194 forks source link

Can i change the flag to the country code? #397

Open adityanegara opened 2 years ago

adityanegara commented 2 years ago

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

catamphetamine commented 2 years ago

What?

michael5r commented 8 months ago

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}