Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

558
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda