简体   繁体   English

注销在 Firebase 中无法使用 React

[英]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.

相关问题 反应本机 firebase onAuthStateChanged 不工作 - react native firebase onAuthStateChanged not working Firebase 无法正常使用 React typescript - Firebase not working with react typescript properly react-native 应用程序在没有登录的情况下崩溃 Firebase 使用带有“where”查询和“in”运算符的“onSnapshot”时身份验证注销 - react-native app crashes without log on Firebase auth logout when using 'onSnapshot' with 'where' query and 'in' operator React Native Firebase 注销 function 在根据用户类型登录后不起作用 - React Native Firebase logout function doesn't work after login based on user type react-firebase单页站点中的注销按钮未更改为登录按钮 - Logout button not changing to login button in react-firebase single page site Firebase function 对于我的 React 应用程序不起作用 - Firebase function for my react app not working 环境变量在反应 firebase 配置文件中不起作用 - environment variable not working in react firebase config file 为什么我的 React Native firebase 登录不起作用? - Why is my react native firebase login not working? React-native 与 Firebase FCM 不工作 - React-native with Firebase FCM not working handleDelete function 在 React Firebase 应用程序中不起作用 - handleDelete function not working in React Firebase app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM