Skip to content

React Query without React Context #8668

Answered by TkDodo
markomitranic asked this question in Ideas
Discussion options

You must be logged in to vote

React Query is not limited to react context, it’s just the easiest way to distribute the queryClient without having to think about it.

You’re totally free to distribute the queryClient how you want, and then pass it manually:

// myApp.tsx
export const queryClient = new QueryClient()

// myComponent.tsx

function MyComponent() {
  const query = useQuery(options, queryClient)
}

You can pass the queryClient as second argument to useQuery (and all other hooks) and we will take that one instead of doing a context lookup.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by markomitranic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants