Open History to see the last commit
1<script lang="ts">
2 import { createQuery, setQueryClientContext } from '../../src/index.js'
3 import type { QueryClient } from '@tanstack/query-core'
4 import type { CreateQueryOptions } from '../../src/index.js'
5β
6 type Props = {
7 queryClient: QueryClient
8 startCount?: number
9 options: (count: number) => CreateQueryOptions<number, Error>
10 }
11β
12 let { queryClient, startCount = 0, options }: Props = $props()
13β
14 let count = $state(startCount)
15β
16 setQueryClientContext(queryClient)
17β
18 const query = createQuery<number, Error>(() => options(count))
19</script>
20β
21<button onclick={() => count++}>increment</button>
22<button onclick={() => query.refetch()}>refetch</button>
23β
24<div data-testid="data">{query.data ?? 'undefined'}</div>
25<div data-testid="status">{query.status}</div>
26<div data-testid="fetchStatus">{query.fetchStatus}</div>
27<div data-testid="isFetching">{query.isFetching}</div>
28<div data-testid="isSuccess">{query.isSuccess}</div>
29<div data-testid="isPlaceholderData">{query.isPlaceholderData}</div>