Skip to content

Commit c316689

Browse files
committed
Fix mobile remix contest prizes tab sometimes not appearing (#11984)
1 parent cc27971 commit c316689

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/mobile/src/screens/track-screen/RemixContestSection.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,11 @@ export const RemixContestSection = ({
8282
const hasPrizeInfo = !!remixContest?.eventData?.prizeInfo
8383

8484
const [index, setIndex] = useState(0)
85-
const [routes] = useState<Route[]>([
86-
{ key: 'details', title: 'Details' },
87-
...(hasPrizeInfo ? [{ key: 'prizes', title: 'Prizes' }] : []),
88-
{ key: 'submissions', title: 'Submissions' }
89-
])
85+
const [routes, setRoutes] = useState<Route[]>([])
9086
const [heights, setHeights] = useState({})
9187
const [firstRender, setFirstRender] = useState(true)
9288
const animatedHeight = useSharedValue(TAB_HEADER_HEIGHT)
93-
const currentHeight = heights[routes[index].key]
89+
const currentHeight = heights[routes[index]?.key]
9490
const previousHeight = usePrevious(currentHeight)
9591
const hasHeightChanged = currentHeight !== previousHeight
9692

@@ -100,6 +96,14 @@ export const RemixContestSection = ({
10096
}
10197
}, [firstRender])
10298

99+
useEffect(() => {
100+
setRoutes([
101+
{ key: 'details', title: 'Details' },
102+
...(hasPrizeInfo ? [{ key: 'prizes', title: 'Prizes' }] : []),
103+
{ key: 'submissions', title: 'Submissions' }
104+
])
105+
}, [hasPrizeInfo])
106+
103107
const handleLayout = (key: string) => (e: any) => {
104108
const height = e.nativeEvent.layout.height
105109
setHeights((prev) => {

0 commit comments

Comments
 (0)