Skip to content

Question about interaction of the queryClient instance with the React Query Devtools cache view when using Jotai Atoms #2764

Answered by rothsandro
juse122 asked this question in Q&A
Discussion options

You must be logged in to vote

As mentioned in the docs:

[...] be sure to wrap the root of your project in a <Provider> and initialise queryClientAtom with the same queryClient value you provided to QueryClientProvider.

There is also an example that shows you how to do it. You can use useHydrateAtoms to initialize the queryClientAtom with your custom query client:

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>
    </Q…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@rothsandro
Comment options

@tatwater
Comment options

@juse122
Comment options

@rothsandro
Comment options

@dai-shi
Comment options

Answer selected by juse122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants