Skip to content

Commit 9a82950

Browse files
author
marbemac
committed
fix: copy state properties over for ssr hydration
Signed-off-by: marbemac <[email protected]>
1 parent 5c9a953 commit 9a82950

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/solid-query/src/createBaseQuery.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,20 @@ export function createBaseQuery<
6363
) => {
6464
return observer.subscribe((result) => {
6565
notifyManager.batchCalls(() => {
66-
const unwrappedResult = { ...unwrap(result) }
66+
const query = observer.getCurrentQuery()
67+
const unwrappedResult = {
68+
...unwrap(result),
69+
70+
// hydrate() expects a QueryState object, which is similar but not
71+
// quite the same as a QueryObserverResult object. Thus, for now, we're
72+
// copying over the missing properties from state in order to support hydration
73+
dataUpdateCount: query.state.dataUpdateCount,
74+
fetchFailureCount: query.state.fetchFailureCount,
75+
fetchFailureReason: query.state.fetchFailureReason,
76+
fetchMeta: query.state.fetchMeta,
77+
isInvalidated: query.state.isInvalidated,
78+
}
79+
6780
if (unwrappedResult.isError) {
6881
if (process.env['NODE_ENV'] === 'development') {
6982
console.error(unwrappedResult.error)

0 commit comments

Comments
 (0)