-
I would be great to have an option that allows us to keepPreviousData but also have the status have the This would be useful because it can be utilized to show a loading state when loading takes longer than a specified amount of time. I there any way to achieve this with the current API? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The This is the state we want to avoid with |
Beta Was this translation helpful? Give feedback.
-
You can achieve the desired behavior using a combination of |
Beta Was this translation helpful? Give feedback.
The
loading
state signalizes a "hard" loading - which means a state where you have no data yet and also no error. You want to always show a loading spinner / indicator here.This is the state we want to avoid with
keepPreviousData
, so this is intentional. What you are looking for is probably theisFetching
flag that is also returned. This flag is true whenever a request is going out, no matter why. So it will also be true for background refetches, like when you focus the window or when you are fetching with previous data kept like in your example.