Skip to content

How can I access the queryClient from outside the context? #4743

Answered by TkDodo
jmbldwn asked this question in Q&A
Discussion options

You must be logged in to vote

you create a queryClient somewhere, so you can most certainly export and import it:

- const queryClient = new QueryClient()
+ export const queryClient = new QueryClient()

there are reasons why this can be troublesome in some cases, which I have listed here:

So I think you can also setup the socket io client in the react app lifecycle to gain access to the queryClient with useQueryClient. But you don't have to - it's just about weighing tradeoffs.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@rickvian
Comment options

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