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

flat-fuchsia
flat-fuchsia9/29/2023

how to invalidate data through mutation key?

Hi m fetching a data through post request so whenever user will upload new document below table i want to refresh how to do?? Anyone kindly guide
No description
ratty-blush
ratty-blush9/29/2023

InvalidatateQuery problem

Custom Hooks ```ts export const useAddUnitMutation = () => { const { queryClient } = useQueryClientInstance();...
sunny-green
sunny-green9/28/2023

useQueries - Accessing meta information in errors

Using V4 Hey 👋 I've tried finding resources on this but came up short. I'm somewhat inspired by the v5 version of useQueries and combine....
flat-fuchsia
flat-fuchsia9/28/2023

whats the best way to handle error state ?

i dont want to set these on every file so i put here is this correct way or wrong ?
No description
provincial-silver
provincial-silver9/28/2023

V5-RC: replicate `keepPreviousData` behaviour for pagination

I'm trying to move to the v5 release candidate and facing a blocker here. Scenario: I've got a useQuery which calls a paginated API for a list of posts. With v4, on page change, I was able to keep the keep the previous query's data on the screen using the keepPreviousData flag until the new request was resolved (success or error)....
equal-aqua
equal-aqua9/27/2023

context returns null on error so I was not able to go tot previous stage

Hi All, I am using useMutation in react. I want to implement optimistic update.It is working fine when it is success. When error occures I could not reset to previous value as I am getting context as undefined in the event of error. appreciate helping to solve this ... ...
No description
rising-crimson
rising-crimson9/27/2023

InvalidateQuery does not trigger refetch.

This must be a really noob issue but for some reason I have trouble triggering refetch with invalidateQuery(). I have a grid and a details panel and I would like to reload the details panel when user clicks on a row. User could also edit the info so therefore I'd prefer useQuery instead of just useEffect for this page. But the panel doesn't change until I force the entire view to refetch with window focus refetching. All I have is ``` queryClient.invalidateQueries({ queryKey: ["itemversions"], refetchType: "all"...
sunny-green
sunny-green9/26/2023

When to use queryCache?

Still pretty new to react-query so sorry if this is obvious. I have a pretty nested object I am retrieving from my api, something like 4-5 levels deep, and on the 4th or 5th level there are lets say 10 objects or something. The parent view on the ui I am driving needs bit of all of the data at first which is why I am originally fetching the data all in on go, and then you click on stuff and it takes you to a sub view with some of the nested data. Ideally I'd not like to fetch the data again for outer_object.inner_object. I was under the impression that react-query and it's caching abilities would help prevent that. So if I was to click on something to take me to a subview, could I use a queryCache.find('quer-key', someID) here to get the data from the cache when the component (view) loads - thus accessining the overall larger nested object from the previous page/query? Or am I just still not thinking of react-query properly?...
optimistic-gold
optimistic-gold9/26/2023

isFetching and isRefetching

A little bit confused, i have actually gone through tkdodo articule on this, but logging both i get the same result at all times. what are their major difference ?
genetic-orange
genetic-orange9/26/2023

How to set up dependent queries with Suspense

Normally, to create dependent queries, you need to use the "enabled" option. But in the case of Suspense queries, you can't change this option. So, is it possible to make dependent queries while using Suspense?...
ratty-blush
ratty-blush9/25/2023

First response receives no posts, even though a post is created

I have the following useEffect function, that gets triggered whenever data changes. ```javascript const { isSuccess, data } = queryPosts(); ...
blank-aquamarine
blank-aquamarine9/25/2023

Refetch Query when variable change (VUE)

i have 2 pages: 1. BaseInputSearchResults.vue: 2. useLp.ts (Vue/query hook) ...
No description
correct-apricot
correct-apricot9/25/2023

Alternative to onSuccess in useQuery

hello everyone, im kinda new to this react-query and there's something i'm curious about concerning useQuery hook, i want to add the onSuccess and onError property after queryFn but it seems that it's gotten deprecated in v4 and ultimately in v5, is there any workaround to it, i don't want to use status.isSuccess because im not rendering anything instead i want to put some logic after the queryFn succeeds.
stuck-chocolate
stuck-chocolate9/25/2023

Partial update query without refetching everything

HI There, Does anyone know if it's possible to partially update a query without refetching everything? I'm working on a feature that fetches a large array of data from the backend and I want to be able to post individual updates to the backend and have that reflected in the frontend. ...
like-gold
like-gold9/25/2023

how to update query data without useEffect

Hi I'm using Redux and React-Query and i want update response data when api call succeed when i use onSuccess call back it's work but i read onSuccess is not good so i try ...
sunny-green
sunny-green9/24/2023

Read only query ?

I have a page with a lot of "lazy loaded" components (each components represents a game match data) that will make a request with tanstack query. The list of requests is "known in advance" but we can't know how many are loaded if any at all. At the top of my page I want to make a "resume" card with statistics that sums up the data of all the loaded ones....
fair-rose
fair-rose9/22/2023

React Query Disable

In my case how can I delay the API call, untill visible set to true ``` const [visible, setVisible] = useState<boolean>(false); ...
evident-indigo
evident-indigo9/21/2023

Query invalidation concept question

Hello, if we want to invalidate multiple queries with different query keys, do we need to call invalidateQueries() multiple times per query to invalidate? In our case we are using an array as query keys in the following format:
['resource', args]
['resource', args]
Where args is an object. We sometimes want to invalidate multiple resources and thought this would work:...
helpful-purple
helpful-purple9/21/2023

React Query not sharing context correctly in lerna monorepo

I am currently building an internal component library. This library contains a Header and Footer component which both uses the useQuery hook. However, this package is handled by Lerna in a mono repo setup. So my Remix app imports the Header and Footer from the package named "components". Inside the Remix app there is the React Query context provider. like so:...
rare-sapphire
rare-sapphire9/20/2023

useQuery without QueryProvider

I am using react query with nextJs 13 and sometime i want to useQuery without any cache just to use the loading, data, isError functions, is that possible?