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

BaseExample.svelte

32 lines732 Bytes

1<script lang="ts">
2 import type { QueryClient } from '@tanstack/query-core'
3 import {
4 HydrationBoundary,
5 createQuery,
6 setQueryClientContext,
7 } from '../../src/index.js'
8 import type { DehydratedState } from '@tanstack/query-core'
9​
10 type Props = {
11 queryClient: QueryClient
12 dehydratedState: DehydratedState
13 queryFn: () => Promise<string>
14 }
15​
16 let { queryClient, dehydratedState, queryFn }: Props = $props()
17​
18 setQueryClientContext(queryClient)
19​
20 const query = createQuery(() => ({
21 queryKey: ['string'],
22 queryFn,
23 }))
24</script>
25​
26<HydrationBoundary
27 state={dehydratedState}
28 options={undefined}
29 queryClient={undefined}
31 <div>data: {query.data ?? 'undefined'}</div>
32</HydrationBoundary>