mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at session-alignment 28 lines 973 B view raw
1import {useNavigationState} from '@react-navigation/native' 2import {getTabState, TabState} from 'lib/routes/helpers' 3 4export function useNavigationTabState() { 5 return useNavigationState(state => { 6 const res = { 7 isAtHome: getTabState(state, 'Home') !== TabState.Outside, 8 isAtSearch: getTabState(state, 'Search') !== TabState.Outside, 9 isAtFeeds: getTabState(state, 'Feeds') !== TabState.Outside, 10 isAtNotifications: 11 getTabState(state, 'Notifications') !== TabState.Outside, 12 isAtMyProfile: getTabState(state, 'MyProfile') !== TabState.Outside, 13 } 14 if ( 15 !res.isAtHome && 16 !res.isAtSearch && 17 !res.isAtFeeds && 18 !res.isAtNotifications && 19 !res.isAtMyProfile 20 ) { 21 // HACK for some reason useNavigationState will give us pre-hydration results 22 // and not update after, so we force isAtHome if all came back false 23 // -prf 24 res.isAtHome = true 25 } 26 return res 27 }) 28}