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