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

fix cannot get dialCode of undefined #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MacKentoch
Copy link

@MacKentoch MacKentoch commented Sep 29, 2018

I was using a custom country picker (not sure it happens in other cases, but fix is good for all).

I had a bug in case when user deletes (rather than enters his phone number) pre-rendered country code: dailCode of undefined error.

lib/index.js Outdated
@@ -76,13 +76,16 @@ export default class PhoneInput extends Component {
key: index,
image: Flags.get(country.iso2),
label: country.name,
dialCode: `+${country.dialCode}`,
dialCode: `+${(country && country.dialCode) || ''}`,
Copy link
Contributor

@jling90 jling90 Oct 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line change necessary? PhoneNumber.getCountryDataByCode returns an array of objects. If country is a null-type it's going to crash on the line above anyway.

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

Successfully merging this pull request may close these issues.

2 participants