-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I access a suspenseQuery's state while in-flight? #73
Comments
Suspense Query doesn't have fetching status. Its created in a way to always have data as defined and hence the status is always 'success'. If you want to use previous state, you would typically want to use startTransition With the unwrap util, you can understand when the promise is pending. query in your example would be undefined when the promise is pending. This is helpful if you only want to know if a promise is pending or not. |
I think you're referring to I want a loader to be displayed alongside the data when the query is fetching, even after the query has already resolved initially. I suppose I could build something with unwrap where if the query is pending I can assume it to be fetching and if it's not I can access the fetchStatus property but that does not seem very elegant |
Seems right. Sorry about the misunderstanding earlier.
Do you have an api in mind? Maybe we can come up with an abstraction to improve DX? |
@Esya I'm not 100% sure that it is what You need:
As far as I see @kalijonn If You are open to adding some abstraction-atoms, then I have few in mind already, some related to this case, and some related to changes introduced in version |
I have the following, typical, suspenseQuery atom :
I would like to derive a status atom/access the other properties of the query (or the query key without duplicating the logic) but if I try to make a derive read atom :
I essentially want to build something similar to pmndrs/jotai#2228 to have stale-while-revalidate content but also want to get the properties of the query instead of just basing myself on the status of the promise. Any idea? Thanks!
The text was updated successfully, but these errors were encountered: