about summary refs log tree commit diff
path: root/src/lib/hooks/useNavigationTabState.web.ts
blob: 704424781ab1c735731f5c744468d3f36ca4b85b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import {useNavigationState} from '@react-navigation/native'
import {getCurrentRoute} from 'lib/routes/helpers'

export function useNavigationTabState() {
  return useNavigationState(state => {
    let currentRoute = state ? getCurrentRoute(state).name : 'Home'
    return {
      isAtHome: currentRoute === 'Home',
      isAtSearch: currentRoute === 'Search',
      isAtNotifications: currentRoute === 'Notifications',
      isAtMyProfile: currentRoute === 'MyProfile',
    }
  })
}