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

119
Visualizações
UseEffect is working without of focus react navigation

im have two screens at same stack

    <TravelStack.Navigator
      screenOptions={{
        headerTitle:"",
        headerStyle:{
          backgroundColor:"black"
        },
        
        headerLeft:()=><Ionicons name="menu-outline" 
        size={30} 
        style={{marginLeft:6}}
        color="#45c7e8" />,

        headerRight:()=> <Ionicons name="notifications-outline" style={{marginRight:6}} size={30} color="#45c7e8" />
      }}
    >
      <Tabs.Screen 
        name="Travel" 
        component={Viajes}
        options={{
          unmountOnBlur: true
        }}
      />
      <Tabs.Screen 
        name="Conductor" 
        component={ConductorOptionsScreen} 
        options={{
          unmountOnBlur: true
        }}
      /> 
      </TravelStack.Navigator>

And im calling two metods using useEffect at "Travel" screen

const isFocused = useIsFocused();  

useEffect(() => {
    setLoading(true)
    verifyState()
    const interval = setInterval(() => {
      verifyState()
    }, 60000);
    return () => clearInterval(interval); 
 }, [isFocused]);

when im navigate to screen 2 in this case "Conductor Screen" After a while the method "setLoading" is working but im not calling this method into "verifyStateFunction", im triying to use the options "unmountOnBlur" but does not working could someone help me understand what is going on?

update im triying replace method for this but does not working

useEffect(() => {
    const unsubscribe = navigation.addListener('focus', () => {  
      setLoading(true)
      verifyState()
    });
    return unsubscribe;
  }, [navigation])

useEffect(() => {
   const interval = setInterval(() => {
    verifyState()
   }, 60000);
    return () => clearInterval(interval); 
}, []);

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