【发布时间】:2020-03-25 07:11:53
【问题描述】:
我有一个简单的组件来检查用户是否登录。
在 20% 的情况下它可以正常工作,但在另外 80% 的情况下,页面只是永远加载,因为 firebase.auth().onAuthStateChanged 从未被触发或在加载几分钟后被触发。
会发生什么?
class Loading extends Component {
componentDidMount() {
this.checkIfLoggedIn();
}
checkIfLoggedIn = () => {
console.warn("checking if logged in")
firebase.auth().onAuthStateChanged(
user => {
console.warn('AUTH STATE CHANGED CALLED ', user)
if (user) {
console.log("there is indeed a user")
this.props.navigation.navigate('Main');
} else {
console.log("go authenticate")
this.props.navigation.navigate('Auth');
}
}
);
};
render() {
return (
<View style={styles.container}>
<Text>Please wait there</Text>
<ActivityIndicator size="large" />
</View>
);
}
}
【问题讨论】:
-
你在使用@react-native-firebase/auth
-
可能是网络问题
标签: firebase react-native firebase-authentication