TanStack

T

TanStack

TanStack is a community of passionate software engineers striving for high-quality, open-source software for web devs

Join

react-query-questions

solid-query-questions

table-questions

virtual-questions

router-questions

react-charts-questions

ranger-questions

vue-query-questions

svelte-query-questions

bling-questions

form-questions

angular-query-questions

start-questions

db-questions

start-showcase

router-showcase

📣-announcements

helpful-purple
helpful-purple6/29/2023

Usage from within a Vue plugin

I am looking to create a Vue plugin that needs to be able to access the cache and refetch if necessary. Is this even possible considering useQuery can only be used in a setup function?
flat-fuchsia
flat-fuchsia6/17/2023

Refecth using cache instead execute queryFn

It is possible to "refetch" withouth execute queryFn when is on cache? this is my simply code: ```ts import axios from 'axios'; import { AjaxResponse, AvailableSelect } from '@/types';...
vicious-gold
vicious-gold6/15/2023

Is there a working example of how to properly use in Nuxt/SSR?

I've set this up in Nuxt 3, like so: ```ts const { data,...
vicious-gold
vicious-gold6/15/2023

Getting `Hydration node mismatch` in nuxt 3

I've set up vue-query as a nuxt plugin as explained in the docs, but now I always seem to get a hydration error. Is this a bug? Is there a working example somewhere?...
rising-crimson
rising-crimson6/7/2023

useQuery is rerunning when route query / param change ?

Some of my useQuery composables depend on route query or route param like userId. I pass the query param to useQuery queryKey with Vue 3.3 toRef (toRef(() => route.query.userId)). I wrap like... ```...
other-emerald
other-emerald5/10/2023

Query on user action while respecting cache

Hi everyone ! I'm trying out Vue (Nuxt) and tanstack query currently, and I'm trying to create a query that only fetch data when a user makes an action (ex: a search when the user click on a submit button). For that, I use enable: false and the refetch() method, but, unless I'm mistaken, this method ignore the cache and the request is fired every time. Is there a way to make it work ?...
stormy-gold
stormy-gold5/6/2023

Vue Query Reactive SWR

Hello, folks! I'm new to Query (using it in a Vue3 application) I have a couple of queries that look similar this one. https://gist.github.com/jarrettgreen/0c8b504dc0f736515162bfb517e3e3d7 - The 'feels bad' vibes going off is using ref within the query, the boilerplate needed for SWR cache to work, and this leans on onSuccess in a bad way, which is deprecated. I feel like I'm overthinking something and am just overall not using query correctly. Any thoughts on this would be greatly appreciated! Edit:...
round-purple
round-purple5/4/2023

how to filter data while maintaining minimum results per page?

When using useInfiniteQuery with a select function to remove some results is there a way to do it so the amount of results per page remains consistent where each result moves back 1 when a result is removed
equal-aqua
equal-aqua4/14/2023

Default Mutation Fn ?

Hi, is there a way to make a default mutation Fn like the default query Fn for all mutations ? as i do not wish to keep writing the same fetch function for mutations too i tried the below but doesn't work on useMutation ...
equal-aqua
equal-aqua4/13/2023

useQuery Fetching twice?!

hi, i am new the tanstack query. this is my first time using, i followed the guide, however when call "onRefreshCaptcha" the network fetch is doing twice for "captcha_img" ``` const isImgLoading = ref(false) const queryClient = useQueryClient()...
No description
flat-fuchsia
flat-fuchsia4/12/2023

How to assign useQuery's "data" to a Pinia composition store Ref?

Hi, I'm trying to use vue-query with Pinia in order to share data across my app, but still make use of vue-query's great features, such as providing all the different states of fetching and refetching automatically. However, I am not sure if this is an anti-pattern. In this snippet, "expeses.value" would be of type ObjectRefImp instead of Array which creates some unexepcted results. For example in the "pop()" function I get an Error taht pop is not a method of express.value. Is there a correct approach to this...? 👀 ...
No description
round-purple
round-purple4/4/2023

How to utilize useQuery to update multiple variables?

Currently I am passing multiple reactive variables into useQuery and setting there values in the select function as well as cross referencing data from different endpoints to generate newly formatted data. this works but im not sure if this is the best design. since the useQuery is triggered whenever the querykey changes it makes it easy for these values to be updated along with the new request. but should i use using a watcher in the component to update these values? the select function logic i...
sensitive-blue
sensitive-blue3/31/2023

Query Key Array not Updating with key is changed

I'm running into an issue where my query key array isn't updating when I change a selected warehouse ID in a dropdown menu. As a result, useQuery is using old query data instead of fetching new data for the selected warehouse ID. I'm not sure how to update the query key array when the selected warehouse ID changes, and I was wondering if you could provide any guidance on how to resolve this issue? Thank you! I've attached a video to this message that explains the issue in more detail. ```js...
correct-apricot
correct-apricot3/7/2023

Nuxt 3 persistent cache

I'm trying to convert the Nuxt SSR plugin example into a localstorage persister. But i'm getting stuck on the different QueryClients between the @tanstack/vue-query package and the @tanstack/query-core package. Did anyone manage to get this to work in Nuxt 3? This is my plugin at the moment but it fails on the QueryClient ...
variable-lime
variable-lime3/6/2023

cancelQueries Promise doesn't resolve in Cypress/Storybook

Using the "Optimistic Updates" documentation, I created a mutation that uses queryClient.cancelQueries({ queryKey: [myQueryKey] }). Running the app locally with a real backend behaves as expected. However in both Cypress tests and in Storybook (both with HTTP requests mocked), the onMutate function gets stuck on cancelQueries, because the Promise never resolves....
skilled-lime
skilled-lime2/20/2023

I cannot install vue-query with Vue.use using @vue/compat

Hi, I've been trying to find a solution for a few hours now and I'm just really stuck on this one. I'm currently in the process of converting our Vue 2.7 codebase to Vue 3 using @vue/compat but I cannot get vue-query to install properly. Because I cannot switch vue-i18n to the Vue 3 version without reconverting all of my modules first I decided to keep the Vue 2 version for now. That means I have to use Vue.use to install plugins. However I can't get vue-query to install that way, it seems like there's something that is not working with vue-demi and vue/compat because it was working just fine on Vue 2.7 and my other Vue 2 plugins are installed properly with Vue.use....
passive-yellow
passive-yellow2/15/2023

life cycle timing problem with useQuery

My application needs to load general config data via an ajax request. This config contains things like BASE_URL, STALE_TIME and other constants. When I initialize my useQuery, I need these constants to set up the request. Here's a code snippet to help understanding the problem: `const store = useStore();...
xenial-black
xenial-black2/8/2023

Is it possible to simple pass in props to the query key?

```ts <script lang="ts" setup> import { clientClient } from "@/clients/clientClient"; import { useQuery } from "@tanstack/vue-query"; import { useAutocomplete } from "@/composables/useAutocomplete";...
ambitious-aqua
ambitious-aqua2/8/2023

Memory leak in SSR

Hi, I'm using the latest Vue Query plugin with vite-plugin-ssr. As suggested by the docs, the client is created for each request and the cache time is unset, so it defaults to Infinity during SSR. Queries are fetched using suspense. I noticed that my app leaked memory on every request so I analyzed some heap dumps and found that there are many Vue Query instances that cannot be garbage collected because there are active subscription listeners (set by Vue Query, not by me). As a workaround, I do client.unmount() at the end of a request which removes those. Is this a bug or due to wrong usage?...
ambitious-aqua
ambitious-aqua2/8/2023

How to use `useQuery` on route change?

I'd like to refetch data if a route parameter has changed and I tried using vue-router's onBeforeRouteUpdate hook in the setup function but it gives me an error saying Error: vue-query hooks can only be used inside setup() function.. Is there a suggested way to achieve the same functionality? Should I watch the route object instead?