fix: proper prefetch
This commit is contained in:
1 parent
c9ca262da8
commit
3b954279f7
9 files changed
+12
-15
No files matched your search
@@ -25,7 +25,7 @@ export const MobileNavigation = () => {
|
||||
<DropdownMenuContent className='flex w-44 flex-col gap-2 p-2'>
|
||||
{paths.map(({ path, title }) => (
|
||||
<DropdownMenuItem key={path} asChild>
|
||||
<Link href={path}>
|
||||
<Link href={path} prefetch={path !== '/'}>
|
||||
<div>
|
||||
<Button className='relative w-full' variant={currentPath === path ? 'default' : 'outline'}>
|
||||
{title}
|
||||
@@ -47,7 +47,7 @@ export const DesktopNavigation = () => {
|
||||
return (
|
||||
<Nav tabs={paths} active={active || paths[0]}>
|
||||
{({ path, title }) => (
|
||||
<Link href={path}>
|
||||
<Link href={path} prefetch={path !== '/'}>
|
||||
<div>{title}</div>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { atom, getDefaultStore, useAtom } from 'jotai';
|
||||
|
||||
import randomQuery from '@/data/queries/random';
|
||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||
import useMounted from '@/hooks/useMounted';
|
||||
|
||||
const indexAtom = atom(0);
|
||||
|
||||
@@ -15,9 +16,10 @@ interface Props {
|
||||
}
|
||||
|
||||
const useRandomMovie = ({ page }: Props) => {
|
||||
const isMounted = useMounted();
|
||||
const [index, setIndex] = useAtom(indexAtom);
|
||||
|
||||
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery({ page }));
|
||||
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery({ page, suspense: false }));
|
||||
|
||||
if (movies.length && !movies[index]) {
|
||||
setIndex(0);
|
||||
|
||||
Reference in new issue
Block a user