Skip to content

Commit

Permalink
chore(examples): Resolve duplicate first page and incorrect rendering…
Browse files Browse the repository at this point in the history
… start (#785)
  • Loading branch information
SaeWooKKang authored Aug 9, 2024
1 parent a3bf66a commit 06d631e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/react/infinite-scroll/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function fetchServerPage(
): Promise<{ rows: Array<string>; nextOffset: number }> {
const rows = new Array(limit)
.fill(0)
.map((e, i) => `Async loaded row #${i + offset * limit}`)
.map((_, i) => `Async loaded row #${i + offset * limit}`)

await new Promise((r) => setTimeout(r, 500))

Expand All @@ -37,8 +37,8 @@ function App() {
} = useInfiniteQuery({
queryKey: ['projects'],
queryFn: (ctx) => fetchServerPage(10, ctx.pageParam),
getNextPageParam: (_lastGroup, groups) => groups.length,
initialPageParam: 1,
getNextPageParam: (lastGroup) => lastGroup.nextOffset,
initialPageParam: 0,
})

const allRows = data ? data.pages.flatMap((d) => d.rows) : []
Expand Down

0 comments on commit 06d631e

Please sign in to comment.