useSWRInfinite behaves weird #2682
-
in the docs says default of const getKey = (pageIndex: number, url: string, prev: any) => {
console.log(`${url}?page=${pageIndex}`, prev);
return `${url}?page=${pageIndex}`;
};
export default function CustomPagination<T extends IProductResponse>({ url, children }: { url: string; children(props: T): React.ReactElement }) {
const { data, isLoading } = useSWRInfinite<T>((index, prev) => getKey(index, `${url}`, prev), fetcher);
} |
Beta Was this translation helpful? Give feedback.
Answered by
ahmadxgani
Jun 21, 2023
Replies: 1 comment
-
ahh it seems |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ahmadxgani
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ahh it seems
initialSize
is for amount of request not the number of pagination, for workaround, i manually increment pageIndex +1 to get the index 1 in the first request