gpt4 book ai didi

javascript - 为什么当远程调试未激活时我的用户为空,而当其激活时它是一个对象?

转载 作者:行者123 更新时间:2023-12-03 01:49:15 25 4
gpt4 key购买 nike

当我远程使用调试 js 时,我的用户not null,而当我不远程使用调试 js 时,我的用户为 null。这是我的代码,用于检查用户是否已登录,然后将他定向到正确的组件:

componentDidMount(){
that=this;
this.authSubscription = firebaseRef.auth().onAuthStateChanged((user) => {
if (user) {
firebaseRef.database().ref('/users/'+user.uid+'/info').once('value').then(function(snapshot) {
if (snapshot.val() !== null) {
that.setState({
haveInfo: true,
loading: false,
user: true,
})
}else{
this.setState({
loading: false,
user: true,
haveInfo: false,
})
}
});
}else{
that.setState({
user: false,
haveInfo: false,
loading: false,
});
}
});
}

render() {
if (this.state.loading) {
//Welcome screen
return <Welcome />
}

if (this.state.user) {
if (this.state.haveInfo) {
//the user set up his info
return <Main />
}else{
//If the user didnt set up his info
return <ProfileSettingUp />
}
}

// If the user is null
return <MainLogToSignUpProceses />

}

我不知道为什么会发生这种情况。感谢您的帮助。

最佳答案

好吧,我无法直接从你的代码中回答你的问题,但是,你应该知道,当你启用远程 js 调试时,你正在使用浏览器的 JS 运行时而不是移动的 JS 运行时。因此,这两个运行时中可能存在缺失的函数或不同的实现。

更多信息请参阅这篇文章:You should not always rely on remote debugging (React Native)

关于javascript - 为什么当远程调试未激活时我的用户为空,而当其激活时它是一个对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50491391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com