Firebase currentUser问题,即使在登录时也是如此

Firebase currentUser问题,即使在登录时也是如此,firebase,firebase-authentication,Firebase,Firebase Authentication,我遇到这样一种情况,在从提供者重定向登录后,相同的代码告诉我currentUser为null,即使我在网络控制台中看到数据。最重要的是,如果我刷新它是好的。但是在重定向之后,用户仍然是空的 我尝试了auth()。onAuthStateChanged,但不起作用 感谢您的见解。这不是auth,而是auth(),应该可以: firebase.auth().onAuthStateChanged(user => { if(user) { console.log(user.u

我遇到这样一种情况,在从提供者重定向登录后,相同的代码告诉我currentUser为null,即使我在网络控制台中看到数据。最重要的是,如果我刷新它是好的。但是在重定向之后,用户仍然是空的

我尝试了auth()。onAuthStateChanged,但不起作用


感谢您的见解。

这不是
auth
,而是
auth()
,应该可以:

firebase.auth().onAuthStateChanged(user => {
    if(user) {
        console.log(user.uid);
    }
});

对不起,打错了。我确实使用了auth(),但它不起作用。