How to achieve loading state between fetches when using refetchInterval
#9428
-
ScenarioUpon page load I call an API to display live data for the user. This API is not guaranteed to return anything on the first try, so I use I'd like to display a loading state for the entire duration of this polling attempt: first load, subsequent refetches, and the time in between because I know there will be multiple refetch attempts. Here's a simplified version of the code: The above code will flicker the "Still loading..." state in and out, because WorkaroundThe docs helped me find this solution: QuestionI'm wondering if there's a better way to go about this using
Potential feature requestIf I understood some of the inner workings of the Admittedly I think my use case is quite niche and this new state won't be useful for many scenarios; I imagine If that's the case, and it is too niche, perhaps the same |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I would probably make the |
Beta Was this translation helpful? Give feedback.
I would probably make the
queryFnerror if the API doesn’t return anything, and then useretryto do the retries. The query will stay inpendingstate until all retries are done.