Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: navigate to second track and you cannot hit the previous button (#1129)

Fahad6e2077b65c5b
diff --git a/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx b/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx
index dd5ff3c7..19e60f97 100644
--- a/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx
+++ b/apps/web/src/app/[locale]/challenge/_components/challenge-track-navigation.tsx
@@ -42,17 +42,17 @@ export function ChallengeTrackNavigation({ challenge, track, isCollapsed, classN
const next = useMemo(() => {
if (currentIndex === null) return null;
- const index = currentIndex + 1;
- return index < trackDetails!.trackChallenges.length
- ? trackDetails!.trackChallenges[index]
+ const nextIndex = currentIndex + 1;
+ return nextIndex < trackDetails!.trackChallenges.length
+ ? trackDetails!.trackChallenges[nextIndex]
: null;
}, [currentIndex, trackDetails]);
const previous = useMemo(() => {
if (currentIndex === null) return null;
- const index = currentIndex - 1;
- return index > 0 ? trackDetails!.trackChallenges[index] : null;
+ const prevIndex = currentIndex - 1;
+ return prevIndex >= 0 ? trackDetails!.trackChallenges[prevIndex] : null;
}, [currentIndex, trackDetails]);
if (isPending || track === null || trackDetails === null || trackDetails === undefined)