1
- import React , { useCallback , useEffect , useRef } from 'react' ;
1
+ import React , { useCallback , useContext , useEffect , useRef } from 'react' ;
2
2
import { ActivityIndicator , Animated , Dimensions , Platform , Pressable , View } from 'react-native' ;
3
3
import FastImage from 'react-native-fast-image' ;
4
4
import styled , { css } from 'styled-components/native' ;
@@ -16,7 +16,7 @@ import { useNavigation } from '@react-navigation/native';
16
16
import { calculateProgressTranslation } from '@/components/Progresstrack' ;
17
17
import { NavigationProp } from '@/screens/types' ;
18
18
import { ShadowWrapper } from '@/components/Shadow' ;
19
- import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs' ;
19
+ import { BottomTabBarHeightContext } from '@react-navigation/bottom-tabs' ;
20
20
import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
21
21
22
22
export const NOW_PLAYING_POPOVER_MARGIN = 6 ;
@@ -112,7 +112,13 @@ function NowPlaying({ offset = 0, inset }: { offset?: number, inset?: boolean })
112
112
const { index, track } = useCurrentTrack ( ) ;
113
113
const { buffered, position } = useProgress ( ) ;
114
114
const defaultStyles = useDefaultStyles ( ) ;
115
- const tabBarHeight = useBottomTabBarHeight ( ) ;
115
+
116
+ // The regular `useBottomTabBarHeight` hook will throw an error when it
117
+ // cannot find a height. Since we might use this component in places where
118
+ // it is unavailable, we'll just use the context directly, which will output
119
+ // `undefined` when it's not set.
120
+ const tabBarHeight = useContext ( BottomTabBarHeightContext ) ;
121
+
116
122
const insets = useSafeAreaInsets ( ) ;
117
123
const previousBuffered = usePrevious ( buffered ) ;
118
124
const previousPosition = usePrevious ( position ) ;
0 commit comments