Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Getting array of object when changing country in react-native-phone-number-input

$
0
0

I am using react-native-phone-number-input in my project. I am also using formik inside it

Below is my code:

const textChangeHandler = (text: any) => {  var getCode = phoneInput.current?.getCallingCode();  var getText = '+'+ getCode + text;  form.setFieldTouched(field.name);  form.setFieldValue(field.name, getText);  console.log('>>', getText);  if (onUpdate) {    onUpdate(getText);  }};<PhoneInput  ref={phoneInput}  defaultValue={''}  defaultCode="US"  layout="first"  onChangeCountry={value => {    textChangeHandler(value);  }}  onChangeText={textChangeHandler}  autoFocus/>

I have to pass the written number with country code into form.setFieldValue. It is working fine if I select country first and then write my number, if I do this then I am getting >> +11234567890 in console. But if I write the number first and then select country the I am getting >> +1[object Object].

I am not able to figure out where I am making mistake.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>