'Every time i refreshes my app it logs out even though i've used this onAuthStateChanged. Below is my code of loading screen
I'm using this screen to navigate between two screens by using the onAuthStateChanged but still every time It refresh the app it logs out even though I'm not log out.
import { View, Text, ActivityIndicator } from 'react-native'
import React, {useEffect } from 'react'
import { auth } from '../firebase';
import { useNavigation } from '@react-navigation/native';
const LoadingScreen = () => {
const navigation = useNavigation()
useEffect(() => {
const unsubscribe = auth.onAuthStateChanged(user =>{
if(user){
navigation.replace('Chats')
//navigate to chat screen if user is exists
}else{
navigation.replace('Welcome')
//else navigate to first screen if no user
}
})
return unsubscribe
},[])
return (
<View >
<ActivityIndicator size='large' />
</View>
);
}
export default LoadingScreen
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
