Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out country code automatically? #67

Open
jnazander opened this issue Mar 28, 2018 · 3 comments
Open

Figure out country code automatically? #67

jnazander opened this issue Mar 28, 2018 · 3 comments

Comments

@jnazander
Copy link

Hi,

This component seems to be only good for registration forms (i.e. when the phone number doesn't exist yet), because the selected country always has to be supplied manually.

But what if I want to use this component to edit an already existing phone number? Why do I still need to specify the selected country manually? Can you make it so that the country is automatically parsed from the phone number's country code?

For example, if I provide +37255530593 as the value, it should automatically set Estonia as the country code. Right now it always sets Afghanistan, (unless another country is manually provided)

With the way it is now, I first need to use some other library to parse the country from the phone number, and then supply that country to ReactPhoneInput, which is a lot of redundant work.

@BuildWithLal
Copy link

BuildWithLal commented Aug 18, 2018

same situation when updating existing phone number. Input show default country code while phone number as different country dial up code.

@jnazander
Copy link
Author

I'm currently using Google's libphonenumber-js instead (https://github.com/catamphetamine/libphonenumber-js) - it has everything you need, including automatically parsing the country as the user types in the phone!

@BuildWithLal
Copy link

Thanks @jnazander ....That did the magic....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants