#useQuery() in recursive component - how to know when all fetches are complete

7 messages · Page 1 of 1 (latest)

tough ibex
#

I'm working on a rendering a tree-like structure (think of nested folders where each folder needs it's own fetch request). What's the best way to know when all the descendant queries are completed to render everything at once?

I first reached for <Suspense> and useSuspenseQuery() however useSuspenseQuery() doesn't support enabled (there are some reasons why I need to conditionally run the query).

#

useQuery() in recursive component - how to know when all fetches are complete

sly dove
#

What are the reasons why you need to conditionally run the query?

jagged gorge
#

how to know when all fetches are complete

useIsFetching() returns the count of running fetches

tough ibex
#

Thanks! I think useIsFetching() might work.

#

What are the reasons why you need to conditionally run the query?
The child components don't need to render based on a signal in the response at the parent level. So the enabled param was really helpful for this. It would be great if useSuspenseQuery also supported enabled but I saw a post somewhere explaining it was an intention decision not to do this.