useQuery infinite retry #2755
Unanswered
mheinzelman
asked this question in
Q&A
Replies: 1 comment
-
your conditional mounting creates an infinite loop. Here is what happens:
the easiest fix would be to implement proper error handling somewhere. Do not mount ComponentTwo if the query is erroneous. You can also only mount it if you actually have data:
This will stop the recursion, but it always display LOADING on the screen. Again, handle errors somewhere (in ComponentOne, in an Error Boundary, ...) and the problem will go away :) |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Hello! I am running into a problem were if one of my queries throws an error it will infinitely retry.
I have a parent component that calls a query like this and renders its child based on if the query is loading or not. In the query below you will see i am simulating an error.
that query is consumed by this component
ComponentTwo uses a query with a refetch interval that is set to -1 onError. This query is also dependent on the data from useQueryOne.
usePollingQuery:
When simulating an error in useQueryOne, it infinitely retries this query and I cannot figure out why. Here is a code sandbox: https://codesandbox.io/s/infallible-chatelet-gpk3w?file=/src/queryHooks.ts
I would really appreciate any help! I would love to get this to throw one error and then stop calling the queryfn
Beta Was this translation helpful? Give feedback.
All reactions