diff --git a/src/components/MorePhotos.tsx b/src/components/MorePhotos.tsx index 136c4317..2774eebf 100644 --- a/src/components/MorePhotos.tsx +++ b/src/components/MorePhotos.tsx @@ -15,10 +15,6 @@ export default function MorePhotos({ }) { const router = useRouter(); - if (prefetch) { - router.prefetch(path); - } - const [isPending, startTransition] = useTransition(); const buttonRef = useRef(null); @@ -27,6 +23,12 @@ export default function MorePhotos({ router.push(path, { scroll: false }); }), [router, path]); + useEffect(() => { + if (prefetch) { + router.prefetch(path); + } + }, [router, path, prefetch]); + useEffect(() => { const observer = new IntersectionObserver(e => { if (triggerOnView && e[0].isIntersecting) {