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

568
Views
React Native : Async and Await is a reserved word error inside onPress

I'm facing a weird problem. In my react native app I have a Googlebutton which trigger onPress and it will check the condition within it, but the problem is I have await reserved word which returns me an error says Unexpected reserved word await I'm trying to apply Pincode

Main Code

 import PINCode, {hasUserSetPinCode,resetPinCodeInternalStates,deleteUserPinCode,
 } from "@haskkor/react-native-pincode";

<GoogleSigninButton
   style={{ width: 252, height: 58 }}
   size={GoogleSigninButton.Size.Wide}
   color={GoogleSigninButton.Color.Dark}
   onPress={() => {

   const hasPin = await hasUserSetPinCode();
   if (fingerprint === true) {
       googleLogin();
   }

   else if (hasPin) {
       console.log("Alert pinnn should pop up");
   }

   else {
      console.log("Alert should pop up");
      setModalVisible(true);
    }
   }
 }
/>

This is what I've tried I've put async (hasUserSetPinCode) before the await but it returns no value in my console, it seems it's not working

putting an async

import PINCode, {hasUserSetPinCode,resetPinCodeInternalStates,deleteUserPinCode,
}from "@haskkor/react-native-pincode";

<GoogleSigninButton
     style={{ width: 252, height: 58 }}
     size={GoogleSigninButton.Size.Wide}
     color={GoogleSigninButton.Color.Dark}
     onPress={async() => {
     /* ------------------ The async below Doesn't work ----------------------------------- */
     
     const hasPin = await hasUserSetPinCode();
        if (fingerprint === true) {
           googleLogin();
        }
        else if (hasPin) {
           console.log("Alert pinnn should pop up");
        }
        else {
           console.log("Alert should pop up");
           setModalVisible(true);
        }
     }
  
/>

enter image description here

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

0

Place async before the function in which it is used.

import PINCode, {hasUserSetPinCode,resetPinCodeInternalStates,deleteUserPinCode,
 } from "@haskkor/react-native-pincode";

<GoogleSigninButton
   style={{ width: 252, height: 58 }}
   size={GoogleSigninButton.Size.Wide}
   color={GoogleSigninButton.Color.Dark}
   onPress={async () => {

   const hasPin = await hasUserSetPinCode();
   if (fingerprint === true) {
       googleLogin();
   }

   else if (hasPin) {
       console.log("Alert pinnn should pop up");
   }

   else {
      console.log("Alert should pop up");
      setModalVisible(true);
    }
   }
 }
/>
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!