Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

123
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda