Skip to content

Commit

Permalink
pass children to StreamedHydration
Browse files Browse the repository at this point in the history
  • Loading branch information
nitedani committed Dec 2, 2023
1 parent 2f8beb4 commit f46e324
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/vike-react-query/renderer/StreamedHydration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { StreamedHydration }
import type { QueryClient } from '@tanstack/react-query'
import { dehydrate, hydrate, DehydratedState } from '@tanstack/react-query'
import { uneval } from 'devalue'
import type { ReactNode } from 'react'
import { useStream } from 'react-streaming'

declare global {
Expand All @@ -18,7 +19,7 @@ declare global {
* - hydrating the query client on the client
* - if react-streaming is not used, it doesn't do anything
*/
function StreamedHydration({ client }: { client: QueryClient }) {
function StreamedHydration({ client, children }: { client: QueryClient; children: ReactNode }) {
const stream = useStream()

if (import.meta.env.SSR && stream) {
Expand Down Expand Up @@ -48,5 +49,5 @@ function StreamedHydration({ client }: { client: QueryClient }) {
}
window._rqd_ = { push: onEntry }
}
return null
return children
}
11 changes: 5 additions & 6 deletions packages/vike-react-query/renderer/VikeReactQueryWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ export default function VikeReactQueryWrapper({ pageContext, children }: VikeRea
const queryClient = __queryClientGlobal ?? new QueryClient(queryClientConfig)

return (
<>
<StreamedHydration client={queryClient} />
<QueryClientProvider client={queryClient}>
<FallbackErrorBoundary>{children}</FallbackErrorBoundary>
</QueryClientProvider>
</>
<QueryClientProvider client={queryClient}>
<FallbackErrorBoundary>
<StreamedHydration client={queryClient}>{children}</StreamedHydration>
</FallbackErrorBoundary>
</QueryClientProvider>
)
}

Expand Down

0 comments on commit f46e324

Please sign in to comment.