[英]Logout is not working in Firebase with React
Using firebase for user auth, sign up and login is working well, but logout is not working and don't know how to check.使用 firebase 进行用户身份验证,注册和登录工作正常,但注销不工作,不知道如何检查。 Here is my code
这是我的代码
Logout.js注销.js
const { currrentUser, logout } = useAuth();
const handleLogout = async (e) => {
e.preventDefault();
setError("");
try {
await logout();
navigate("/login");
} catch {
setError("Failed to logout");
}
};
<div className="btn-container">
<button onClick={() => setLogoutModal(false)}>Cancel</button>
<button onClick={handleLogout}>Logout</button>
</div>
Auth.js授权.js
function logout() {
return auth().signOut();
}
Feel free to ask more details欢迎询问更多详情
Although in many documentations, signOut()
function took no argument.尽管在许多文档中, signOut
signOut()
function 没有参数。 I changed signOut()
in Auth.js to signOut(auth)
.我将 Auth.js 中的 signOut
signOut()
更改为 signOut signOut(auth)
。 And now it works.现在它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.