Skip to content

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

chore: prefetch active AOT challenges

bautistaaa30fe87344327
diff --git a/apps/web/src/app/[locale]/aot-2023/_components/tiltable-card.tsx b/apps/web/src/app/[locale]/aot-2023/_components/tiltable-card.tsx
index 640657d7..5960f116 100644
--- a/apps/web/src/app/[locale]/aot-2023/_components/tiltable-card.tsx
+++ b/apps/web/src/app/[locale]/aot-2023/_components/tiltable-card.tsx
@@ -3,7 +3,7 @@
import { motion } from 'framer-motion';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
-import { useRef, useState, type MouseEvent } from 'react';
+import { useRef, useState, type MouseEvent, useEffect } from 'react';
import type { Challenges } from './card-grid';
import clsx from 'clsx';
@@ -105,6 +105,13 @@ export function TiltableCard({ index, challenge }: Props) {
}, 100);
};
+ useEffect(() => {
+ if (!challenge.isRevealed) {
+ return;
+ }
+ router.prefetch(`/challenge/${challenge.slug}`);
+ }, [challenge, router]);
+
return (
<motion.div
onClick={handleClick}