Skip to content

Commit 1afcfd1

Browse files
committed
refactor(svelte-query/HydrationBoundary): create 'QueryClient' inside component instead of receiving via props
1 parent d4a7688 commit 1afcfd1

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/svelte-query/tests/HydrationBoundary/BaseExample.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
import type { DehydratedState } from '@tanstack/query-core'
99
1010
let {
11-
queryClient,
1211
dehydratedState,
1312
queryFn,
1413
}: {
15-
queryClient: QueryClient
1614
dehydratedState: DehydratedState
1715
queryFn: () => Promise<string>
1816
} = $props()
1917
18+
const queryClient = new QueryClient()
2019
setQueryClientContext(queryClient)
2120
2221
const query = createQuery(() => ({
@@ -25,6 +24,10 @@
2524
}))
2625
</script>
2726

28-
<HydrationBoundary state={dehydratedState} options={undefined} queryClient={undefined}>
27+
<HydrationBoundary
28+
state={dehydratedState}
29+
options={undefined}
30+
queryClient={undefined}
31+
>
2932
<div>data: {query.data ?? 'undefined'}</div>
3033
</HydrationBoundary>

packages/svelte-query/tests/HydrationBoundary/HydrationBoundary.svelte.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ describe('HydrationBoundary', () => {
2626

2727
it('should hydrate queries to the cache on context', async () => {
2828
const dehydratedState = JSON.parse(stringifiedState)
29-
const queryClient = new QueryClient()
3029

3130
const rendered = render(BaseExample, {
3231
props: {
33-
queryClient,
3432
dehydratedState,
3533
queryFn: () => sleep(20).then(() => 'string'),
3634
},
@@ -39,6 +37,5 @@ describe('HydrationBoundary', () => {
3937
expect(rendered.getByText('data: stringCached')).toBeInTheDocument()
4038
await vi.advanceTimersByTimeAsync(21)
4139
expect(rendered.getByText('data: string')).toBeInTheDocument()
42-
queryClient.clear()
4340
})
4441
})

0 commit comments

Comments
 (0)