Description
Describe the bug
When using the QueryClientProvider
in an npm package and requiring the query client via useQueryClient
in the consumer app, I am always getting the following error:
Error: No QueryClient set, use QueryClientProvider to set one
It seems like the logic for getting the shared context is broken.
Expected behavior
Using the useQueryClient
should check for the shared ReactQueryClientContext
and use it if existing.
Additional context
With #1912 the context sharing was disabled by default, and seems to have been disabled at all.
It seems like the QueryClientSharingContext
is always false, as it is initialized with that value:
https://github.com/tannerlinsley/react-query/blob/05a8057e2be64915d2a12b716d8131f113598dbd/src/react/QueryClientProvider.tsx#L12
https://github.com/tannerlinsley/react-query/blob/05a8057e2be64915d2a12b716d8131f113598dbd/src/react/QueryClientProvider.tsx#L34
Shouldn't the context be initialized with whether there is a shared context or a boolean value, passed to the useQueryClient
hook?