Mohammad Fareed Alam
Mohammad Fareed Alam

Reputation: 139

How can I convert my phone country code to iso2 in React Native

For example, I have +92 phone code for Pakistan and I want to convert it to iso2( e.g Pakistan's iso2 is 'PK'). So, is there any library to do this? I have tried 'country-code-lookup' but it is giving wrong result.

import * as lookup from 'country-code-lookup';
lookup.byIso(parseInt('+92'))

It should return an object with iso2 'PK', but it is giving me a wrong result. I have also tried lookup.byIso(parseInt('92'), without + at parameter, but still getting wrong result! Your help would be appreciable! Thanks

Link of country-code-lookup : https://github.com/richorama/country-code-lookup

Upvotes: 0

Views: 657

Answers (1)

Sofyane MAKERRI
Sofyane MAKERRI

Reputation: 463

Try to use React Native Phone Number Input package:

https://reactnativecode.com/react-native-phone-number-input/

Upvotes: 1

Related Questions