Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

iso2: country.iso2
}));
}

getCountryCode() {
const countryData = PhoneNumber.getCountryDataByCode(this.state.iso2);
if (!countryData) {
return '';
}
return countryData.dialCode;
}

Expand Down