SvelteStack / svelte-query

Performant and powerful remote data synchronization for Svelte
https://sveltequery.vercel.app
MIT License
814 stars 31 forks source link

`useIsFetching` immediately inside `<QueryClientProvider>` throws #29

Open frederikhors opened 3 years ago

frederikhors commented 3 years ago

Reading https://sveltequery.vercel.app/guides/background-fetching-indicators#displaying-global-background-fetching-loading-state:

If I use useIsFetching immediately inside <QueryClientProvider client={queryClient}> it throws:

Error: No QueryClient set, use QueryClientProvider to set one

I need to use a sub-components for it to work.

Why?

amen-souissi commented 3 years ago

Thanks! useIsFetching in this case is called outside the provider in your case. Try to use the IsFetching component...

frederikhors commented 3 years ago

Oh. Wow. You're right!

Is there any docs for IsFetching cmp?