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

169
Visualizações
Detecting country code for react-native-phone-number

I use the react-native-phone-number-input library. I want the country flag to be determined automatically depending on where I'm from. How do I implement this?

<PhoneInput
  ref={phoneInput}
  defaultValue={value}
  // defaultCode="DM"
  layout="first"
  // onChangeText={(v) => setValue(v)}
  onChangeFormattedText={(v) => setValue(v)}
  placeholder={' '}
  defaultCode="IN"
  withDarkTheme
  withShadow
  autoFocus
  containerStyle={{
    borderRadius: 0,
    width: '100%',
    height: 49,
  }}
  textInputStyle={{height: 68}}
  textContainerStyle={{paddingTop: 15}}
/>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

you can set default country based on IP , hit API Geolocation which return countrycode or something. then return to your apps

about 4 years ago · Juan Pablo Isaza Relatório

0

The react-native-localize package can be used to get the country code of the current users device - and I assume this can just then be passed in to your PhoneNumber component to display the correct country flag.

import * as RNLocalize from "react-native-localize";

console.log(RNLocalize.getCountry());
// -> "FR"

I assume this would then work

<PhoneInput
  ref={phoneInput}
  defaultValue={value}
  // defaultCode="DM"
  layout="first"
  // onChangeText={(v) => setValue(v)}
  onChangeFormattedText={(v) => setValue(v)}
  placeholder={' '}
  defaultCode={RNLocalize.getCountry()}
  withDarkTheme
  withShadow
  autoFocus
  containerStyle={{
    borderRadius: 0,
    width: '100%',
    height: 49,
  }}
  textInputStyle={{height: 68}}
  textContainerStyle={{paddingTop: 15}}
/>
about 4 years ago · Juan Pablo Isaza Relatório
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