Ich benutze react-native-google-signin. Mein Code ist:Anruf Funktion nach currentUserSync - Async Warte auf
async _setupGoogleSignin() {
try {
await GoogleSignin.hasPlayServices({ autoResolve: true });
await GoogleSignin.configure({
webClientId: '<from web>',
offlineAccess: true
});
const user = await GoogleSignin.currentUserAsync()
.then(this._someFunction(user)); // Is this correct?
console.log(user); // this works. User is logged
}
catch(err) {
console.log("Play services error", err.code, err.message);
}
}
_someFunction(user){
console.log("ID: ",user.id) // Error is thrown here
this.setState({id: user.id}); // This is not set
}
Mit dem .then(this._someFunction(user));
, ich will _someFunction
die user
an die Funktion übergeben. Der Fehler lautet Play services error undefined Cannot read property 'id' of undefined
.
Ich möchte in der Lage sein, die Funktion aufzurufen, die user
setzt, wenn GoogleSignin.currentUserAsync()
abgeschlossen ist. Was mache ich falsch?