Replies: 1 comment 1 reply
-
What about using a singleton? Can you see bugs originating for this implementation? it will work if you only have one ReacrQueryProvider and you might need to reset the queryClientScoped in testing.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, I'm struggling to find a way to pass a QueryClient to react-router route loaders when the QueryClient is initialised in a useState.
The React Router docs state, "Due to the decoupling of fetching and rendering in the design of the data APIs, you should create your router outside of the React tree with a statically defined set of routes." Like so:
Also, in the React Query docs when you want to use React Query in a route loader function, you pass the QueryClient to the loader functions like this:
However, it is common to initialise the QueryClient in a useState, for example to set up toasts globally:
In this case how do you pass the QueryClient to the loader functions, considering "you should create your router outside of the React tree"?
Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions