-
- Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Describe the bug
I have initialized QueryClient in main +layout.svelte:
const queryClient = new QueryClient({ defaultOptions: { queries: { enabled: browser, refetchInterval: $dataRefetchIntervalS * 1000 } } }); $: { queryClient.setDefaultOptions({ queries: { ...queryClient.getDefaultOptions().queries, refetchInterval: $dataRefetchIntervalS * 1000 } }); } then, somewhere in my app on route /example i have:
const streamsQuery = createQuery({ queryKey: ['streams'], queryFn: async () => { const res = await fetch(`${PUBLIC_API_KEY}/streams`); const data = await res.json(); return data.map(streamMapper); } }); $: ({ data, status } = $streamsQuery); $dataRefetchIntervalS as reactive store can be changed and should cause that streamsQuery would react to a new value, but its not. StreamsQuery updates it's options only when unmounted and mounted again - while for e.g changing routes withing app.
Your minimal, reproducible example
Steps to reproduce
Reproducted the same behaviour in react and works fine.
Expected behavior
Queries should react to defaultOptions changed by queryClient.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: any
- Browser: any
Tanstack Query adapter
svelte-query
TanStack Query version
5.0.0-beta.15 but also in stable version
TypeScript version
5.0.0
Additional context
No response