use(asyncAtom) #5404
Unanswered
joernroeder
asked this question in
Ideas
use(asyncAtom)
#5404
Replies: 1 comment
-
|
Good idea; if we wanted it to work with Want to try this out in a PR? |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be super handy to have a hook
useAsyncAtom(atom)which awaits the initialisation under the hood and just returns the value. Right now, when usinguseSelector(asyncAtom, () ...)I always have to filter out the other statuses and therefore the return type isundefined | Data.It feels like something with Reacts use() and a suspense boundary could get us there.
I have this helper which allows me to await until the atom is resolved, but hooks obvls don't know. This smells similar to useSuspenseQuery vs useQuery.
Beta Was this translation helpful? Give feedback.
All reactions