We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 211fccc commit 1223516Copy full SHA for 1223516
1 file changed
tests/createInfiniteQuery.test.tsx
@@ -1,17 +1,22 @@
1
import { createInfiniteQuery } from '../src/createInfiniteQuery'
2
3
it('createInfiniteQuery', () => {
4
- type Response = { title: string; content: string }
+ type Response = {
5
+ projects: { id: string; name: string }[]
6
+ nextCursor: number
7
+ }
8
type Variables = { id: number }
9
- const primaryKey = '/posts'
10
+ const primaryKey = '/projects'
11
const variables = { id: 1 }
12
13
const query = createInfiniteQuery<Response, Variables, Error>({
14
primaryKey,
15
queryFn: ({ queryKey: [primaryKey, variables] }) => {
16
return fetch(`${primaryKey}/${variables.id}`).then(res => res.json())
17
},
18
+ defaultPageParam: 1,
19
+ getNextPageParam: lastPage => lastPage.nextCursor,
20
enabled: data => !data,
21
suspense: true,
22
})
0 commit comments