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

100
Views
React Native Navigation in a if statement

Im making PIN code lock screen from react Native. When the user entered correct pin it gives a alert "Login success" When the user entered Wrong pin it gives a alert "Login failed" if user entered PIN 3 times, I want to show a new screen. so I write following code.

const checkPinCode = (a,b) => {
        if(arrayEquals(a,b)){
            alert("Login success")
          }else {
            alert(" Login Failed  ");
            seterrorCounter(errorCounter+1)
          }      
              if (errorCounter>=2){
                 //Navigation code 
                 () => navigation.navigate('Wait')
              }
}

But this does not do the job. How can I navigate screens in a if else statement. You can find the complete code and emulator here - https://snack.expo.dev/@codewithbanchi/pincode

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change your code to:

const checkPinCode = (a,b) => {
        if(arrayEquals(a,b)){
            alert("Login success")
          }else {
            alert(" Login Failed  ");
            seterrorCounter(errorCounter+1)
          }      
              if (errorCounter>=2){
                 //Navigation code 
                 navigation.navigate('Wait') // remove () =>
              }
}

() => navigation.navigate('Wait') defines an unnamed function which es never called.

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!