fix: back to prefetch

This commit is contained in:
ner committed 2024-10-29 18:25:52 +02:00
1 parent a268f7c38d
commit c9ca262da8
14 files changed
+180 -27

No files matched your search

+6 -2
View File
@@ -10,10 +10,14 @@ const indexAtom = atom(0);
export const useSilentIndex = () => getDefaultStore().get(indexAtom);
const useRandomMovie = () => {
interface Props {
page: number;
}
const useRandomMovie = ({ page }: Props) => {
const [index, setIndex] = useAtom(indexAtom);
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery());
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery({ page }));
if (movies.length && !movies[index]) {
setIndex(0);