• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

486
Views
React Native: Async and Await es un error de palabra reservado dentro de onPress

Estoy enfrentando un problema extraño. En mi aplicación nativa de reacción, tengo un botón de Googlebutton que activa onPress y verificará la condición dentro de él, pero el problema es que tengo una palabra reservada en await que me devuelve un error que dice Unexpected reserved word await . Estoy tratando de aplicar Pincode

Código principal

 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); } } } />

Esto es lo que probé. Puse async (hasUserSetPinCode) antes de esperar, pero no devuelve ningún valor en mi consola, parece que no funciona.

poniendo un asíncrono

 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); } } />

ingrese la descripción de la imagen aquí

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

0

Coloque async antes de la función en la que se utiliza.

 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 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error