T
TanStack3y ago
fascinating-indigo

Can I really use useQueryClient outside a component in a normal regular function?

Hi all can I really use useQueryClient outside a component in a normal regular function?
3 Replies
optimistic-gold
optimistic-gold3y ago
You can use it inside a hook if that’s what you’re referring too! But not just any function, whenever you call a react hook inside a function, that function becomes a hook itself and must therefore obey the rules of hooks
metropolitan-bronze
metropolitan-bronze3y ago
Hi. What you can still do is pass your queryClient as parameter or through a store to access it outside of React world.
fascinating-indigo
fascinating-indigoOP3y ago
Very interesting, thanks for the feedback fellows.

Did you find this page helpful?