Skip to content

fix cannot get dialCode of undefined#69

Open
MacKentoch wants to merge 4 commits into
thegamenicorus:masterfrom
MacKentoch:master
Open

fix cannot get dialCode of undefined#69
MacKentoch wants to merge 4 commits into
thegamenicorus:masterfrom
MacKentoch:master

Conversation

@MacKentoch

@MacKentoch MacKentoch commented Sep 29, 2018

Copy link
Copy Markdown

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.

Comment thread lib/index.js Outdated
image: Flags.get(country.iso2),
label: country.name,
dialCode: `+${country.dialCode}`,
dialCode: `+${(country && country.dialCode) || ''}`,

@jling90 jling90 Oct 8, 2018

Copy link
Copy Markdown
Contributor

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