fix: proper prefetch
This commit is contained in:
1 parent
c9ca262da8
commit
3b954279f7
9 files changed
+12
-15
No files matched your search
@@ -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