Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!