<PhoneInput
ref={phoneInput}
defaultValue={phoneNumber}
defaultCode="GB"
layout="second"
withShadow
filterProps
autoFocus
disableArrowIcon
containerStyle={styles.phoneContainer}
textContainerStyle={styles.textInput}
onChangeFormattedText={(text) => {
setphoneNumber(text);
}}
/>
I am using the library ‘react-native-phone-number-input’ so a user can easily enter their number with the country code already there. Right now our app only allows users from the UK so I was wondering if there is a way to only have the ‘GB’ country code with no other country codes available?
I disabled the arrow icon but the user is still able to click on the country code and then given the option to select another.
>Solution :
Hey you can do via passing countryPickerProps as.
<PhoneInput
ref={phoneInput}
defaultValue={phoneNumber}
defaultCode="GB"
layout="second"
withShadow
filterProps
autoFocus
disableArrowIcon
containerStyle={styles.phoneContainer}
textContainerStyle={styles.textInput}
onChangeFormattedText={(text) => {
setphoneNumber(text);
}}
countryPickerProps={{
countryCodes: ['GB'],
}}
/>