thegamenicorus / react-native-phone-input

Phone input box for React Native
https://www.npmjs.com/package/react-native-phone-input
MIT License
394 stars 447 forks source link

How to get country code #24

Closed abhinavsk90 closed 6 years ago

abhinavsk90 commented 6 years ago

If someone is typing the number with country code, I would like to get the country object using which you used to update the flag.

How can i achieve that.

RoyalDeveloper2015 commented 6 years ago

I want to get country code from this too.

abhishekush commented 6 years ago

You can get country code using getDialCode() method from component refs

dbelchev commented 6 years ago

@abhishekush getDialCode returnes country DIAL code as '+1', but you can't directly obtain the country code as 'us', because the documented "getCountryCode" function is not a method of the reference. (I checked the code, there isn't such function in the object). @thegamenicorus can you help with this one?

thegamenicorus commented 6 years ago

Hi all,

v 0.2.1, you can use .getISOCode() to get country code as 'us', 'ca' and etc.