1
0
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:
xmflsct
2023-01-16 22:36:49 +01:00
parent adb7a765b4
commit c2a180f4f5
4 changed files with 10 additions and 7 deletions

View File

@ -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])
}