Skip to main content

Ref Properties — IPhoneInputRef

Source: lib/interfaces/phoneInputRef.ts

The ref prop gives imperative access to the component.

Phone number values

Property / MethodTypeDescription
nationalPhoneNumberstringNational number without country code, digits only (11912345678)
getNationalPhoneNumber()stringMethod form of nationalPhoneNumber
nationalPhoneNumberFormattedstringNational number with formatting applied (11 91234 5678)
getNationalPhoneNumberFormatted()stringMethod form of nationalPhoneNumberFormatted
internationalPhoneNumberstringE.164 — calling code + national number, unformatted (+5511912345678). This is what you persist.
getInternationalPhoneNumber()stringMethod form of internationalPhoneNumber
internationalPhoneNumberFormattedstringCountry calling code + national number with formatting
getInternationalPhoneNumberFormatted()stringMethod form of internationalPhoneNumberFormatted
internationalPhoneNumberLengthnumberTotal digit count of calling code + phone number

:::note National trunk prefix Many countries print their numbers with a leading 0 that is not part of the international number — the example-number placeholder shows it (07400 123456 for the UK). Typing it is fine: nationalPhoneNumber and internationalPhoneNumber drop it, so the E.164 value stays correct. The leading zero is kept where it is significant, as in Italy. :::

Country, validation & line type

Property / MethodTypeDescription
countryICountryCurrently selected country object
getCountry()ICountryMethod form of country
isValidPhoneNumberbooleanWhether the current number is valid for the selected country
phoneNumberTypePhoneNumberType | nullDetected line type of the current number (MOBILE, FIXED_LINE, TOLL_FREE, etc), or null when incomplete/invalid
getPhoneNumberType()PhoneNumberType | nullMethod form of phoneNumberType
propsPhoneInputPropsAll props passed to the component

TextInput methods (forwarded)

MethodDescription
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.