mirror of
				https://github.com/tooot-app/app
				synced 2025-06-05 22:19:13 +02:00 
			
		
		
		
	Fix popToTop dev warning
This commit is contained in:
		| @@ -8,7 +8,7 @@ import Root from './Root' | ||||
| const Stack = createNativeStackNavigator<TabLocalStackParamList>() | ||||
|  | ||||
| const TabLocal: React.FC = () => { | ||||
|   usePopToTop() | ||||
|   usePopToTop('Tab-Local-Root') | ||||
|   return ( | ||||
|     <Stack.Navigator screenOptions={{ headerShadowVisible: false }}> | ||||
|       <Stack.Screen name='Tab-Local-Root' component={Root} /> | ||||
|   | ||||
| @@ -44,7 +44,7 @@ const Root: React.FC< | ||||
| } | ||||
|  | ||||
| const TabNotifications: React.FC = () => { | ||||
|   usePopToTop() | ||||
|   usePopToTop('Tab-Notifications-Root') | ||||
|  | ||||
|   return ( | ||||
|     <Stack.Navigator screenOptions={{ headerShadowVisible: false }}> | ||||
|   | ||||
| @@ -8,7 +8,7 @@ import Root from './Root' | ||||
| const Stack = createNativeStackNavigator<TabPublicStackParamList>() | ||||
|  | ||||
| const TabPublic: React.FC = () => { | ||||
|   usePopToTop() | ||||
|   usePopToTop('Tab-Public-Root') | ||||
|   return ( | ||||
|     <Stack.Navigator screenOptions={{ headerShadowVisible: false }}> | ||||
|       <Stack.Screen name='Tab-Public-Root' component={Root} /> | ||||
|   | ||||
| @@ -1,15 +1,18 @@ | ||||
| import { StackActions, useFocusEffect, useNavigation } from '@react-navigation/native' | ||||
| import { StackActions } from '@react-navigation/native' | ||||
| import { useGlobalStorage } from '@utils/storage/actions' | ||||
| import { useEffect } from 'react' | ||||
| import navigationRef from './navigationRef' | ||||
|  | ||||
| // Mostly used when switching account and sub pages were still querying the old instance | ||||
|  | ||||
| const usePopToTop = () => { | ||||
|   const navigation = useNavigation() | ||||
| const usePopToTop = (name: string) => { | ||||
|   const [accountActive] = useGlobalStorage.string('account.active') | ||||
|  | ||||
|   useEffect(() => { | ||||
|     navigation.dispatch(StackActions.popToTop()) | ||||
|     const currentRoute = navigationRef.getCurrentRoute() | ||||
|     if (currentRoute && currentRoute.name !== name) { | ||||
|       navigationRef.dispatch(StackActions.popToTop()) | ||||
|     } | ||||
|   }, [accountActive]) | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user