You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this library, and I've collected some feedback from colleagues or people I show this hook to.
One persistent subject is that, often developers want to derive the status of the hook, that is, is it loading? is it validating? is there a difference between them at all? is there any data, etc. Refer to: #563
I've made a PR with some tested changes, that do not break other tests, which can be used to discuss and perhaps refine this feature further. At the moment I don't have so much time to spend on discussions, so hopefully the code can explain itself 😅
If there's data and no revalidation happening, stale
If there's error and no revalidating happening, error
If there's revalidation, validating
These would be hard-coded strings, which would allow developers to simply match them.
Today developers have to write the same checks every time, const isLoading = !data && !error and eventually end up getting mixed with isValidating. I also noticed that isValidating seems to get stuck on error cases. I am not sure my PR totally fixed that though.
I have also found use cases where people simply mix isValidating and isLoading under one loading flag, with total disregard to #563, because I guess people don't want to bother searching for answers.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I've been using this library, and I've collected some feedback from colleagues or people I show this hook to.
One persistent subject is that, often developers want to derive the
status
of the hook, that is, is it loading? is it validating? is there a difference between them at all? is there any data, etc. Refer to: #563I've made a PR with some tested changes, that do not break other tests, which can be used to discuss and perhaps refine this feature further. At the moment I don't have so much time to spend on discussions, so hopefully the code can explain itself 😅
#1215
In short:
loading
stale
error
validating
These would be hard-coded strings, which would allow developers to simply match them.
Today developers have to write the same checks every time,
const isLoading = !data && !error
and eventually end up getting mixed withisValidating
. I also noticed thatisValidating
seems to get stuck on error cases. I am not sure my PR totally fixed that though.I have also found use cases where people simply mix
isValidating
andisLoading
under oneloading
flag, with total disregard to #563, because I guess people don't want to bother searching for answers.What are your thoughts?
Beta Was this translation helpful? Give feedback.
All reactions