私はreact-native-google-signinを使用しています。私のコードは次のとおりです。.then(this._someFunction(user));
でcurrentUserSyncの後に関数を呼び出す - Asyncは問題を待ちます
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
}
、私は機能_someFunction
にuser
を渡したいです。
エラーはPlay services error undefined Cannot read property 'id' of undefined
です。
GoogleSignin.currentUserAsync()
が完了したときにuser
を設定する関数を呼び出せます。私は間違って何をしていますか?