Suspense support in type definitions #3470
Replies: 2 comments 2 replies
-
@peterchappy Do you think about something like this? const { data } = useQuery(['users'], () => getUsers(), { suspense: true }) // here type of <data> would be User[], and not User[] | undefined If so, I also had the same thought, because at the moment we are also heavily using some self-written utilities (without suspense feature) to avoid repetitive patters like checking for However, I think as outlined in #3310, there are still edge cases which would prevent omitting the |
Beta Was this translation helpful? Give feedback.
-
exactly, a simple:
would give you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
With React 18 out I've started looking into adopting
Suspense
more broadly across my application. I was wondering if there was any plan to model the types in a way thatUseQueryResult
is able account for when for the option{ suspense: true }
so I don't need to still discriminate onisSuccess
to keep the compiler happy when using suspense?I know that the suspense features are listed as experimental so I started working on a hack of a solution for now but obviously would prefer the types be baked in.
Beta Was this translation helpful? Give feedback.
All reactions