Gathering detailed insights and metrics for @nandorojo/react-native-phone-input
Gathering detailed insights and metrics for @nandorojo/react-native-phone-input
Gathering detailed insights and metrics for @nandorojo/react-native-phone-input
Gathering detailed insights and metrics for @nandorojo/react-native-phone-input
npm install @nandorojo/react-native-phone-input
Typescript
Module System
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
The react-native-phone-input
seems unmaintained, so this is meant to address some bugs.
◻️ Typescript support ◻️ Fix refs support ◻️ Web support
Phone input box for React Native
![]() | ![]() |
---|
yarn add @nandorojo/react-native-phone-input
1import PhoneInput from "@nandorojo/react-native-phone-input"; 2 3export default () => { 4 const ref = useRef(); 5 return <PhoneInput ref={ref} />; 6};
![]() | ![]() |
---|
1componentDidMount(){ 2 this.setState({ 3 pickerData: this.phone.getPickerData() 4 }) 5} 6 7onPressFlag(){ 8 this.myCountryPicker.open() 9} 10 11selectCountry(country){ 12 this.phone.selectCountry(country.iso2) 13} 14 15render(){ 16 return( 17 <View style={styles.container}> 18 <PhoneInput 19 ref={(ref) => { this.phone = ref; }} 20 onPressFlag={this.onPressFlag} 21 /> 22 23 <ModalPickerImage 24 ref={(ref) => { this.myCountryPicker = ref; }} 25 data={this.state.pickerData} 26 onChange={(country)=>{ this.selectCountry(country) }} 27 cancelText='Cancel' 28 /> 29 </View> 30 ) 31}
see full custom picker example
use awesome react-native-country-picker-modal to select country
![]() | ![]() |
---|
1onPressFlag(){ 2 this.countryPicker.openModal() 3} 4 5selectCountry(country){ 6 this.phone.selectCountry(country.cca2.toLowerCase()) 7 this.setState({cca2: country.cca2}) 8} 9 10render(){ 11 return( 12 <View style={styles.container}> 13 <PhoneInput 14 ref={(ref) => { this.phone = ref; }} 15 onPressFlag={this.onPressFlag} 16 /> 17 18 <CountryPicker 19 ref={(ref) => { this.countryPicker = ref; }} 20 onChange={(value)=> this.selectCountry(value)} 21 translation='eng' 22 cca2={this.state.cca2} 23 > 24 <View></View> 25 </CountryPicker> 26 </View> 27 ) 28}
see full custom library picker example
1<PhoneInput countriesList={require("./countries.json")} />
Property Name | Type | Default | Description |
---|---|---|---|
initialCountry | string | 'us' | initial selected country |
allowZeroAfterCountryCode | bool | true | allow user input 0 after country code |
disabled | bool | false | if true, disable all interaction of this component |
value | string | null | initial phone number |
style | object | null | custom styles to be applied if supplied |
flagStyle | object | null | custom styles for flag image eg. {{width: 50, height: 30, borderWidth:0}} |
textStyle | object | null | custom styles for phone number text input eg. {{fontSize: 14}} |
textProps | object | null | properties for phone number text input eg. {{placeholder: 'Telephone number'}} |
textComponent | function | TextField | the input component to use |
offset | int | 10 | distance between flag and phone number |
pickerButtonColor | string | '#007AFF' | set button color of country picker |
pickerBackgroundColor | string | 'white' | set background color of country picker |
pickerItemStyle | object | null | custom styles for text in country picker eg. {{fontSize: 14}} |
cancelText | string | 'Cancel' | cancel word |
confirmText | string | 'Confirm' | confirm word |
buttonTextStyle | object | null | custom styles for country picker button |
onChangePhoneNumber | function(number) | null | function to be invoked when phone number is changed |
onSelectCountry | function(iso2) | null | function to be invoked when country picker is selected |
onPressFlag | function() | null | function to be invoked when press on flag image |
countriesList | array | null | custom countries list |
autoFormat | bool | false | automatically format phone number as it is entered |
Function Name | Return Type | Parameters | Description |
---|---|---|---|
isValidNumber | boolean | none | return true if current phone number is valid |
getNumberType | string | none | return true type of current phone number |
getValue | string | none | return current phone number |
getFlag | object | iso2:string | return flag image |
getAllCountries | object | none | return country object in country picker |
getPickerData | object | nont | return country object with flag image |
focus | void | none | focus the phone input |
blur | void | none | blur the phone input |
selectCountry | void | iso2:string | set phone input to specific country |
getCountryCode | string | none | return country dial code of current phone number |
getISOCode | string | none | return country iso code of current phone number |
onPressCancel | func | none | handler to be called when taps the cancel button |
onPressConfirm | func | none | handler to be called when taps the confirm button |
No vulnerabilities found.
No security vulnerabilities found.