Files
upstream-mirror 3a013ccdfe
Some checks failed
autofix.ci / autofix (push) Failing after 4s
Release / Release (push) Has been skipped
GitHub Actions Security Analysis / Run zizmor (push) Failing after 2s
snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:13:08 +05:00

40 lines
885 B
Svelte

<script lang="ts">
import { QueryClient } from '@tanstack/query-core'
import { createInfiniteQuery } from '../../src/index.js'
import { setQueryClientContext } from '../../src/context.js'
import { sleep } from '@tanstack/query-test-utils'
type Props = {
queryClient: QueryClient
}
let { queryClient }: Props = $props()
const queryKey = ['test']
let firstPage = $state(0)
setQueryClientContext(queryClient)
const query = createInfiniteQuery(() => ({
queryKey: queryKey,
queryFn: ({ pageParam }) => sleep(10).then(() => pageParam),
getNextPageParam: (lastPage) => lastPage + 1,
initialPageParam: firstPage,
}))
</script>
<button
onclick={() => {
queryClient.setQueryData(queryKey, {
pages: [7, 8],
pageParams: [7, 8],
})
firstPage = 7
}}
>
setPages
</button>
<div>Data: {JSON.stringify(query.data)}</div>