-
I'm updating the internals of a data-fetching library to use react-query. We'd like to make the update non-breaking initially, but react-query's error when a Provider can't be found is making that tricky to achieve (I won't go into the architectural details if that's ok). Now I've been looking at using a try/catch around react-query's useQuery, which works, but breaks the rules of hooks. What I'm looking for is the option to use react-query, but for it to not throw when a provider is missing. A more graceful failure state that won't crash the app basically. Is the useQuery hook decoupled enough from the Provider that it could just operate without caching if a Provider can't be found? Because if so, an opt-in mode that will not throw on a missing Provider would be a solution to the problem above. Or alternatively, if that's not possible, a flag that when set will not throw the provider error, but return it under the error returned by the hook for example. Would any of that be in scope for this project? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Not sure how this should work. The Provider provides the QueryClient, which contains the QueryCache with all the data and all the options |
Beta Was this translation helpful? Give feedback.
Not sure how this should work. The Provider provides the QueryClient, which contains the QueryCache with all the data and all the options