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

QueryClientProvider.svelte

21 lines480 Bytes

1<script lang="ts">
2 import { QueryClient } from '@tanstack/query-core'
3 import { onDestroy, onMount } from 'svelte'
4 import { setQueryClientContext } from './context.js'
5 import type { QueryClientProviderProps } from './types.js'
6​
7 const { client = new QueryClient(), children }: QueryClientProviderProps =
8 $props()
9​
10 onMount(() => {
11 client.mount()
12 })
13​
14 setQueryClientContext(client)
15​
16 onDestroy(() => {
17 client.unmount()
18 })
19</script>
20​
21{@render children()}