Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
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
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda