[英]Signin with Login requires Button to click twice to open Google Login Page | Expo | Expo Auth Session
I have setup a login with google functionality in React Native App.我已经在 React Native App 中设置了一个使用谷歌功能的登录名。 The Login Button works and login works too, however the Login Button needs to be clicked twice to open "Sign In with Google" popup.
登录按钮有效,登录也有效,但是登录按钮需要单击两次才能打开“使用 Google 登录”弹出窗口。
The function that handles login is available in my custom authentication hook and is called in of the child components named Login.处理登录的函数在我的自定义身份验证钩子中可用,并在名为 Login 的子组件中调用。
Authenication Hook:认证挂钩:
const SignInWithGoogle = () => {
console.log("clicked");
promptAsync()
.then(async (response) => {
if (response.type === "success") {
const credential = GoogleAuthProvider.credential(
null,
response.authentication.accessToken
);
await signInWithCredential(auth, credential);
}
})
.catch((error) => setError(error))
.finally(() => setLoading(false));
};
Function called on Button click in Login.js在 Login.js 中单击按钮时调用的函数
<Pressable
style={{ backgroundColor: myColors.primary, padding: 20 }}
onPress={SignInWithGoogle}
>
<Text>Login</Text>
</Pressable>
Try doing it like so:尝试这样做:
<Pressable
style={{ backgroundColor: myColors.primary, padding: 20 }}
onPress={() => SignInWithGoogle}
>
<Text>Login</Text>
</Pressable>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.