This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / webapp / features / cards / lib / queries / useCards.tsx
708 B 30 lines
1import { useSuspenseInfiniteQuery } from '@tanstack/react-query'; 2import { getUrlCards } from '../dal'; 3 4interface Props { 5 didOrHandle: string; 6 limit?: number; 7} 8 9export default function useCards(props: Props) { 10 const limit = props?.limit ?? 16; 11 12 const cards = useSuspenseInfiniteQuery({ 13 queryKey: ['cards', props.didOrHandle, limit], 14 initialPageParam: 1, 15 queryFn: ({ pageParam = 1 }) => { 16 return getUrlCards(props.didOrHandle, { 17 limit, 18 page: pageParam, 19 }); 20 }, 21 getNextPageParam: (lastPage) => { 22 if (lastPage.pagination.hasMore) { 23 return lastPage.pagination.currentPage + 1; 24 } 25 return undefined; 26 }, 27 }); 28 29 return cards; 30}