react-native-phone-input
react-native-phone-input copied to clipboard
TypError: undefined is not an object (evaluating 'this.countryPicker.openModal')
When I invoke onPressFlag(){ this.countryPicker.openModal() } by pressing the country flag, I get undefined. Here is the code below:
`import React, { Component } from 'react'; import { StyleSheet, View } from 'react-native';
import PhoneInput from 'react-native-phone-input'; import CountryPicker from 'react-native-country-picker-modal';
export default class Test4 extends React.Component { constructor() { super();
this.onPressFlag = this.onPressFlag.bind(this);
this.selectCountry = this.selectCountry.bind(this);
this.state = {
cca2: 'US',
};
}
componentDidMount() { this.setState({ pickerData: this.phone.getPickerData(), }); }
onPressFlag(){ this.countryPicker.openModal() }
selectCountry(country){ this.phone.selectCountry(country.cca2.toLowerCase()) this.setState({cca2: country.cca2}) }
render(){ return( <View style={styles.container}> <PhoneInput ref={(ref) => { this.phone = ref; }} onPressFlag={this.onPressFlag} />
<CountryPicker
ref={(ref) => { this.countryPicker = ref; }}
onChange={(value)=> this.selectCountry(value)}
translation='eng'
cca2={this.state.cca2}
>
<View></View>
</CountryPicker>
</View>
)
} }
let styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', padding: 20, paddingTop: 60, }, });`
I have the same issue. please, anyone has the solution?. thanks.
Please refer to this my friend. https://github.com/xcarpentier/react-native-country-picker-modal/issues/270#issuecomment-569040444
I have the same issue. I am using this with expo application . Please anyone help. Its urgent.
Thanks in andvance