T
TanStack3y ago
plain-purple

is there an enabled flag on `useSuspenseQuery` in v5 beta?

how can I skip running a query
15 Replies
plain-purple
plain-purpleOP3y ago
running into a lot of issues w/ @tanstack/react-query-next-experimental
plain-purple
plain-purpleOP3y ago
here's providers
No description
plain-purple
plain-purpleOP3y ago
queries.ts
No description
plain-purple
plain-purpleOP3y ago
artists fetch
No description
plain-purple
plain-purpleOP3y ago
No description
plain-purple
plain-purpleOP3y ago
infinite loop of requests on the client - staleTime or anything doesn't seem to work the code is open source and easily runnable if you want to take a look
continuing-cyan
continuing-cyan3y ago
There is no enabled on useSuspenseQuery Can you show a reproduction of that infinite loop?
plain-purple
plain-purpleOP3y ago
Yeah I’m on my phone but it’s on GitHub RelistenNet/relisten-web Branch is app-dir Should just be a yarn and then run. Don’t need any data or server
continuing-cyan
continuing-cyan3y ago
also on mobile 😂 can take a look tomorrow
plain-purple
plain-purpleOP3y ago
haha cool, happy to walk through it together thank you!
continuing-cyan
continuing-cyan3y ago
infinite loop of requests on the client
you're likely missing a suspense boundary
plain-purple
plain-purpleOP3y ago
so that fixed it but it doesn't block on initial render from the server
No description
plain-purple
plain-purpleOP3y ago
obv it loads the fallback state – is there a way to get it to just block? is the only way to prefetch inside of an RSC and then pass that into the react query hydration? also, how can I skip a suspense request? just return early in the queryFn?
const fetchSources = async (slug?: string, year?: string, displayDate?: string) => {
if (!slug || !year || !displayDate) return { sources: [] };

const parsed = await ky(
`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}/${displayDate}`
).json();

return parsed;
};
const fetchSources = async (slug?: string, year?: string, displayDate?: string) => {
if (!slug || !year || !displayDate) return { sources: [] };

const parsed = await ky(
`${API_DOMAIN}/api/v2/artists/${slug}/years/${year}/${displayDate}`
).json();

return parsed;
};
continuing-cyan
continuing-cyan3y ago
Not render the component
sensitive-blue
sensitive-blue3y ago
Im having the same issue with this infinite loop, when using useSuspenseQuery. I wrapped my component (wich uses it) in <Suspense> in the parent component.

Did you find this page helpful?