refactoring: server actions data fetching -> api routes
This commit is contained in:
1 parent
1111712d2c
commit
5cbf93b3b8
38 files changed
+326
-308
No files matched your search
@@ -3,7 +3,7 @@
|
||||
import { startTransition, useCallback } from 'react';
|
||||
import { atom, getDefaultStore, useAtom } from 'jotai';
|
||||
|
||||
import { randomMovies } from '@/api';
|
||||
import randomQuery from '@/api/queries/random';
|
||||
import useInfiniteList from '@/hooks/useInfiniteList';
|
||||
|
||||
const indexAtom = atom(0);
|
||||
@@ -13,11 +13,7 @@ export const useSilentIndex = () => getDefaultStore().get(indexAtom);
|
||||
const useRandomMovie = () => {
|
||||
const [index, setIndex] = useAtom(indexAtom);
|
||||
|
||||
const { shows: movies, fetchNextPage } = useInfiniteList({
|
||||
suspense: true,
|
||||
queryKey: ['random-movie'],
|
||||
queryFn: randomMovies
|
||||
});
|
||||
const { shows: movies, fetchNextPage } = useInfiniteList(randomQuery());
|
||||
|
||||
if (movies.length && !movies[index]) {
|
||||
setIndex(0);
|
||||
|
||||
Reference in new issue
Block a user