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

203
Visualizações
Doing a certain action after pressing the Enter key -React Native

I am using react-native-phone-input package for entering phone number. I want the password field below to open when the user presses the enter key on the keyboard after entering the phone number. There is no such method in the package. How can I do that? Can I just listen for the enter key when the keyboard is turned on and make it go to password input?

import { TextInput, View } from 'react-native';
import React, { useState } from 'react';
import PhoneInput from 'react-native-phone-input';

export default function SignUp({ navigation }) {

  const [password, setPassword] = useState('');
  const [phoneNumber, setPhoneNumber] = useState('');

  return (
    <View >
      <PhoneInput
        ref={ref => { phone = ref }}
        onChangePhoneNumber={setPhoneNumber}
        style={{ width: 150, height: 30, backgroundColor: 'grey' }}
      />
      <TextInput
        onChangeText={setPassword}
        value={password}
        style={{ width: 150, height: 30, backgroundColor: 'grey', marginTop: 20 }}
      />
    </View >
  );
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is a prop in react-native-phone-input that should allow you to handle this as you would with a normal TextInput.

onPressConfirm
func none
handler to be called when taps the confirm button

Thus, you can define a state and use the onPressConfirm function prop to change this state. Then use conditional rendering to hide or show the password input.

import { TextInput, View } from 'react-native';
import React, { useState } from 'react';
import PhoneInput from 'react-native-phone-input';

export default function SignUp({ navigation }) {

  const [password, setPassword] = useState('');
  const [phoneNumber, setPhoneNumber] = useState('');
  const [confirm, setConfirm] = useState(false)

  return (
    <View >
      <PhoneInput
        ref={ref => { phone = ref }}
        onChangePhoneNumber={setPhoneNumber}
        style={{ width: 150, height: 30, backgroundColor: 'grey' }}
        onPressConfirm={() => setConfirm(true)}
      />
      { confirm &&
      <TextInput
        onChangeText={setPassword}
        value={password}
        style={{ width: 150, height: 30, backgroundColor: 'grey', marginTop: 20 }}
      />}
    </View >
  );
}
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