【发布时间】:2020-12-11 03:59:25
【问题描述】:
您好,如果用户可用或不在组件内,我正在尝试返回状态。
我要做的是return true 如果用户登录else false
我正在使用fire base给出的方法来跟踪用户的登录状态
firebase.auth().onAuthStateChanged
这是我的代码。
const isLoggedIn = firebase.auth().onAuthStateChanged(user => {
console.log(!!user)
return !!user;
});
const showSaveTheProgressButton:boolean = isLoggedIn;
但是当我尝试从这个方法返回布尔值时,我得到的是别的东西而不是布尔值
Type 'false | Unsubscribe' is not assignable to type 'boolean'.
上面是我从程序中得到的错误声明。
据我了解,该程序不应该返回Unsubscribe 对
【问题讨论】:
标签: typescript firebase firebase-authentication