Question about interaction of the queryClient instance with the React Query Devtools cache view when using Jotai Atoms #2764
-
Hello, I'm using Jotai together with Tanstack Query and Tanstack's React Query Devtools, and I just can't figure out how to use both the "default" queryClient of Tanstack Query that I instantiate by using
and the full functionality of the React Query Devtools when using the Jotai Atoms While the caching works as expected, I can't see any cache entries in the Devtools and also can't interact with the cache with methods like But the strangest thing about all this is that when I instead use the
then the Devtools work perfectly fine and I can see all cache entries and use said methods. The app is purely frontend without any server components and stuff, and has a functioning This is the Provider setup thats currently working:
The Ultimately, I'd very much like to use the default Tanstack Sadly the Jotai documentation touches the topic of queryClients only very briefly, so I'm not sure if I'm just missing something obvious that is setup-related or if it's something else. Thank you and Best regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
As mentioned in the docs:
There is also an example that shows you how to do it. You can use const queryClient = new QueryClient()
const HydrateAtoms = ({ children }) => {
useHydrateAtoms([[queryClientAtom, queryClient]])
return children
}
export const App = ({ children }) => {
return (
<QueryClientProvider client={queryClient}>
<Provider>
<HydrateAtoms>
{children}
</HydrateAtoms>
</Provider>
</QueryClientProvider>
)
} |
Beta Was this translation helpful? Give feedback.
As mentioned in the docs:
There is also an example that shows you how to do it. You can use
useHydrateAtoms
to initialize thequeryClientAtom
with your custom query client: