Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

Select.svelte

24 lines719 Bytes

1<script lang="ts">
2 import { createQuery, setQueryClientContext } from '../../src/index.js'
3 import type { QueryClient } from '@tanstack/query-core'
4 import type { Accessor, CreateQueryOptions } from '../../src/index.js'
5​
6 type Data = { name: string }
7​
8 type Props = {
9 queryClient: QueryClient
10 options: Accessor<CreateQueryOptions<Data, Error, string>>
11 }
12​
13 let { queryClient, options }: Props = $props()
14​
15 setQueryClientContext(queryClient)
16​
17 const query = createQuery<Data, Error, string>(options)
18</script>
19​
20<div data-testid="status">{query.status}</div>
21<div data-testid="data">{query.data ?? 'undefined'}</div>
22<div data-testid="error">
23 {(query.error as Error | null)?.message ?? 'null'}
24</div>