使用firebase进行用户认证,注册和登录运行良好,但注销不工作,不知道如何检查。以下是我的代码
注销.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>
授权js
function logout() {
return auth().signOut();
}
- 请随意询问更多详情 *
1条答案
按热度按时间bzzcjhmw1#
虽然在很多文档中,
signOut()
函数没有参数,但是我在Auth.js中将signOut()
改为signOut(auth)
,现在它可以工作了。