Skip to content

Commit 93e0523

Browse files
committed
fix: Bind QueryClient to SeamQueryProvider lifecycle
1 parent 35ec479 commit 93e0523

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/lib/seam/SeamProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function SeamProvider({
8989
disabled={disableTelemetry}
9090
endpoint={endpoint}
9191
>
92-
<SeamQueryProvider {...props}>
92+
<SeamQueryProvider {...props} queryClient={globalThis.seamQueryClient ?? props.queryClient}>
9393
<Provider value={value}>
9494
<Telemetry>{children}</Telemetry>
9595
</Provider>

src/lib/seam/SeamQueryProvider.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
useContext,
1111
useEffect,
1212
useMemo,
13+
useState,
1314
} from 'react'
1415

1516
import { useSeamClient } from './use-seam-client.js'
@@ -55,14 +56,13 @@ type SeamClientOptions = SeamHttpOptionsWithClientSessionToken
5556

5657
export type SeamQueryProviderClientOptions = Pick<SeamClientOptions, 'endpoint'>
5758

58-
const defaultQueryClient = new QueryClient()
59-
6059
export function SeamQueryProvider({
6160
children,
6261
onSessionUpdate = () => {},
6362
queryClient,
6463
...props
6564
}: SeamQueryProviderProps): JSX.Element {
65+
const [defaultQueryClient] = useState(new QueryClient())
6666
const value = useMemo(() => {
6767
const context = createSeamQueryContextValue(props)
6868
if (
@@ -88,9 +88,7 @@ export function SeamQueryProvider({
8888
const { Provider } = seamContext
8989

9090
return (
91-
<QueryClientProvider
92-
client={queryClient ?? globalThis.seamQueryClient ?? defaultQueryClient}
93-
>
91+
<QueryClientProvider client={queryClient ?? defaultQueryClient}>
9492
<Provider value={value}>
9593
<Session onSessionUpdate={onSessionUpdate}>{children}</Session>
9694
</Provider>

0 commit comments

Comments
 (0)