Hello,
I am trying to adjust the maximum length of the PhoneInput according to the country of choice. However, I cannot get the ISOCode. When I use the getISOCode() method I get an error: TypeError: undefined is not an object (evaluating 'this.phone.getISOCode').
Here is my code:
/**
@format
@flow
*/
import React, {Component} from 'react';
import { StyleSheet, View, Button} from 'react-native';
import PhoneInput from 'react-native-phone-input';
Hello, I am trying to adjust the maximum length of the PhoneInput according to the country of choice. However, I cannot get the ISOCode. When I use the getISOCode() method I get an error: TypeError: undefined is not an object (evaluating 'this.phone.getISOCode'). Here is my code: /**
import React, {Component} from 'react'; import { StyleSheet, View, Button} from 'react-native'; import PhoneInput from 'react-native-phone-input';
export default class App extends Component {
getMaxLenght=()=>{ this.setState({code:this.phone.getISOCode()}) if (this.state.code==='lb'){ return 14; } if(this.state.code==='us'){ return 15; } if(this.state.code==='ca'){ return 15; } if (this.state.code==='gr'){ return 16; } }
render() { return (
} }
const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, flagStyle:{ width: 40, height: 30, borderWidth:0 },
numberStyle:{ fontSize: 20,
phoneStyle:{ marginHorizontal:60 } });
I tried using the other PhoneInput functions, I get the same result. Any ideas?