Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

fix(PhoneInput): Cast null to empty string #40

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Changes from all commits
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: 3 additions & 2 deletions src/Form/PhoneInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ function PhoneInput({ countryCode, forwardedRef, value: propValue, onKeyDown, on
throw new Error(`${countryCode} is not supported`);
}

const format = (value = '') => {
const parsed = parseDigits(value).substr(0, getRawMaxLength(countryCode, value));
const format = value => {
const phoneString = value || '';
const parsed = parseDigits(phoneString).substr(0, getRawMaxLength(countryCode, phoneString));
return new AsYouType(countryCode).input(parsed);
};

Expand Down