Skip to content

Commit b9a6c66

Browse files
committed
fix: prevent error on lyrics screen when tab height is unavailable
1 parent b03d449 commit b9a6c66

File tree

1 file changed

+9
-3
lines changed
  • src/screens/Music/overlays/NowPlaying

1 file changed

+9
-3
lines changed

src/screens/Music/overlays/NowPlaying/index.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useCallback, useEffect, useRef } from 'react';
1+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
22
import { ActivityIndicator, Animated, Dimensions, Platform, Pressable, View } from 'react-native';
33
import FastImage from 'react-native-fast-image';
44
import styled, { css } from 'styled-components/native';
@@ -16,7 +16,7 @@ import { useNavigation } from '@react-navigation/native';
1616
import { calculateProgressTranslation } from '@/components/Progresstrack';
1717
import { NavigationProp } from '@/screens/types';
1818
import { ShadowWrapper } from '@/components/Shadow';
19-
import { useBottomTabBarHeight } from '@react-navigation/bottom-tabs';
19+
import { BottomTabBarHeightContext } from '@react-navigation/bottom-tabs';
2020
import { useSafeAreaInsets } from 'react-native-safe-area-context';
2121

2222
export const NOW_PLAYING_POPOVER_MARGIN = 6;
@@ -112,7 +112,13 @@ function NowPlaying({ offset = 0, inset }: { offset?: number, inset?: boolean })
112112
const { index, track } = useCurrentTrack();
113113
const { buffered, position } = useProgress();
114114
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+
116122
const insets = useSafeAreaInsets();
117123
const previousBuffered = usePrevious(buffered);
118124
const previousPosition = usePrevious(position);

0 commit comments

Comments
 (0)