React native Error "No QueryClient set, use QueryClientProvider to set one"
Hey, i am having a problem with React Native integration of tanstack react query. Here is my code:
Any help?
6 Replies
genetic-orange•3y ago
Maybe try using a stabilized query client
Or maybe, move your query-client provider above the
<Host /> wrapper, since that seems to be component, which could be rerendered I suppose, and the QueryClientProvider is just for context.national-gold•3y ago
What is the issue?
foreign-sapphireOP•3y ago
No QueryClient set, use QueryClientProvider to set one => getting that as an error in React Native app. @julien
national-gold•3y ago
Ah yeah sorry I missed the title. Where is the error triggered in your code? Usually this happens when calling
useQuery from a component that is not a descendant of <QueryClientProvider>.
For example you'll get this error if you call useQuery (or any other tanstack query hook) from inside <Host> since it's above <QueryClientProvider>.foreign-sapphireOP•3y ago
I moved the QueryClientProvider on top and it works, so Host was killing it.
genetic-orange•3y ago
Yup, whenever that host component rerendered it probably was killing the context provider for the query client