Ref Properties — IPhoneInputRef
Source: lib/interfaces/phoneInputRef.ts
The ref prop gives imperative access to the component.
Phone number values
| Property / Method | Type | Description |
|---|---|---|
nationalPhoneNumber | string | National number without country code (digits only) |
getNationalPhoneNumber() | string | Method form of nationalPhoneNumber |
nationalPhoneNumberFormatted | string | National number with formatting applied |
getNationalPhoneNumberFormatted() | string | Method form of nationalPhoneNumberFormatted |
internationalPhoneNumber | string | Country calling code + national number (digits only) |
getInternationalPhoneNumber() | string | Method form of internationalPhoneNumber |
internationalPhoneNumberFormatted | string | Country calling code + national number with formatting |
getInternationalPhoneNumberFormatted() | string | Method form of internationalPhoneNumberFormatted |
internationalPhoneNumberLength | number | Total digit count of calling code + phone number |
Country, validation & line type
| Property / Method | Type | Description |
|---|---|---|
country | ICountry | Currently selected country object |
getCountry() | ICountry | Method form of country |
isValidPhoneNumber | boolean | Whether the current number is valid for the selected country |
phoneNumberType | PhoneNumberType | null | Detected line type of the current number (MOBILE, FIXED_LINE, TOLL_FREE, etc), or null when incomplete/invalid |
getPhoneNumberType() | PhoneNumberType | null | Method form of phoneNumberType |
props | PhoneInputProps | All props passed to the component |
TextInput methods (forwarded)
| Method | Description |
|---|---|
focus() | Focus the input |
blur() | Blur the input |
clear() | Clear the input |
isFocused() | Returns true if the input is focused |
setNativeProps(props) | Set native props on the underlying TextInput |
measure(callback) | Measure component dimensions |
measureInWindow(callback) | Measure dimensions relative to the window |
measureLayout(node, onSuccess, onFail) | Measure position relative to another node |
tip
ref.isValidPhoneNumber uses the currently selected country automatically. The exported isValidPhoneNumber(phoneNumber, country) function requires passing the country explicitly — useful for validation outside the component.
Example
See the useRef example for a complete working snippet.