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);
}, []);