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)
getNationalPhoneNumber()stringMethod form of nationalPhoneNumber
nationalPhoneNumberFormattedstringNational number with formatting applied
getNationalPhoneNumberFormatted()stringMethod form of nationalPhoneNumberFormatted
internationalPhoneNumberstringCountry calling code + national number (digits only)
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

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.