Skip to content

Hydration is broken, "No QueryClient set" #2112

@Ephem

Description

@Ephem

Describe the bug

Hydration is broken. This can also be seen in the Next.js-example:

No QueryClient set, use QueryClientProvider to set one

The /hydration-package has at some point (v3 release?) switched from import { useQueryClient } from 'react-query' to import { useQueryClient } from '../react'. This bundles the useQueryClient code into the hydration package itself, which also means a separate QueryClientSharingContext gets created there. This is line 124 in dist/react-query-hydration.development.js:

var QueryClientSharingContext = /*#__PURE__*/React.createContext(false);

Because this context is different from the one QueryClientProvider uses, the hydration package can't find a queryClient to work with.

I plan to fix this but wanted to document the bug as soon as I found it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions