componentDidMount(){
this.setState({
pickerData: this.phone.getPickerData()
})
}
onPressFlag(){
this.myCountryPicker.open()
}
selectCountry(country){
this.phone.selectCountry(country.iso2)
}
render(){
return(
<View style={styles.container}>
<PhoneInput
ref={(ref) => { this.phone = ref; }}
onPressFlag={this.onPressFlag}
onPressFlag(){
this.countryPicker.openModal()
}
selectCountry(country){
this.phone.selectCountry(country.cca2.toLowerCase())
this.setState({cca2: country.cca2})
}
// Updates the Flag on change
onPhoneInputChange = (value, iso2) => {
const newState = {
phoneInputValue: value,
};
if (iso2) {
newState.countryCode = iso2?.toUpperCase();
}
this.setState(newState);
}
render(){
Note: if you just need custom styles for the flag image, you can pass the flagStyle prop, only use renderFlag if you need to change what components are actually rendered within the touchable area of the flag.