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

202
Views
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 answers
Answer question

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 Report
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!