T
TanStack2y ago
rival-black

V5: Using useSuspenseQueries with enabled = false

I've seen some comments here and there about how enabled is not supported by useSuspenseQuery (though nothing is documented in migration guide). I was wondering how one might migrate from using useQueries with suspense=true, and some queries being conditional to the new useSuspenseQueries. V4
const [query1, query2] =
useQueries({
queries: [
{ ...query1Options, suspense: true },
{ ...query2Options, enabled: someCondition, suspense: true }
],
});
const [query1, query2] =
useQueries({
queries: [
{ ...query1Options, suspense: true },
{ ...query2Options, enabled: someCondition, suspense: true }
],
});
1 Reply
rival-black
rival-blackOP2y ago
I Might have actually just answered my own question. I think the most sane option is to split the queries up. Any that CAN be disabled, put into a call to useQueries and any that can't, use with useSuspenseQueries. This however does change the behaviour in that we no longer suspend over that first set at all, which would still be ideal. I feel like what I really want for useSuspenseQuery is the ability to define a disableWithPlaceholder option, which must be the same type as the return value and it concurrently disables the query.

Did you find this page helpful?