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

like-gold
like-gold2/5/2024

How to handle nested objects without re-render the whole app?

App example: user has columns, columns has todos, each todo has a done checkbox that can be toggled on and off, basic stuff How should I manage the requests to this use-case? One request to fetch all data? or split the data fetch into individual requests for each column? At some point, the entry data will have to be refetched/mutated/optimistic updated, and this will change the entry data reference and trigger a re-render to my whole app....
No description
national-gold
national-gold2/5/2024

query cache performance

is there any significant difference between using const {data} = useSomething(params) or inifite query and useSomething(params)...
conscious-sapphire
conscious-sapphire2/5/2024

structuralSharing=true should return same object on unchanged data even if queryKey changes

I thought structuralSharing=true will always return the same object reference if the server data is unchanged regardless of changes done in the queryKey. Is this a wrong assumption?
genetic-orange
genetic-orange2/5/2024

Cache Invalidation not working on consecutive updates

``` import { useQuery } from '@tanstack/react-query'; import { QueryKeys } from 'queries/keys'; import { fetcher } from 'utils/fetcher'; ...
rival-black
rival-black2/5/2024

is there a way to call server function using useQuery hook

e.g filename.ts ```ts "use server"...
inland-turquoise
inland-turquoise2/4/2024

Does getQueryData function return a reference to the cached data?

Suppose I have a cached product. I have the following: const product = queryClient(["Product","some_id"]); //Knowing that, the product price is 20 at the beginning. // Some code here product.price = 14;...
harsh-harlequin
harsh-harlequin2/4/2024

Serialize dates with SSR / react-query

Is there a nice/automatic way to serialize/deserialize dates in react-query when doing SSR hydration? (I'm using next.js). useQuery doesn't seem to have a deserialize fn - so whatever gets put in there will be wrong. react-query in general doesn't seem well designed / thoughtful for SSR. Am I missing something?...
ambitious-aqua
ambitious-aqua2/4/2024

Strongly typing useQueries

Hi I am trying to use useQueries, and I have doubt with Typescript, I am trying to call multiple fetch functions in useQueries and it returns an array of combined types. I was wondering is there any way to strongly type the array with query v5: in the given code, is there any way to return the types like [string, date, number] considering those functions returns these types correspondingly? ```const { data, isSuccess, isError } = useQueries({...
conscious-sapphire
conscious-sapphire2/4/2024

queryclient

Not being able to fetch my chats properly using useInfiniteQuery
fair-rose
fair-rose2/4/2024

multiple filters, infinite scroll and a search input

I need to write a useInfiniteQuery where search filters can be unset, the query key will be just the: [entity], there can be one filter: [entity, filter], or multiple filters selected: [entity, ??], and with an optional search string. All using pagination and infinite scroll. What should I put as my query key for multiple filters or is it better to change the backend query dynamically and keep adding the newer results to the same query cache while storing old results? Can someone show me the best approach to this problem? ...
fascinating-indigo
fascinating-indigo2/4/2024

How to trigger query in one component and view it in another?

I have a component that has a dropdown that when summited should trigger a query, I put the query in a custom hook like ```js import { useQuery } from "@tanstack/react-query"; import { PublicUserTypeArray } from "@/types/types";...
frail-apricot
frail-apricot2/2/2024

Bug in Query ESLint exhaustive-deps + question about plugin access

Hello, I've found little bug, which couldn't be reported in Github since there is no public access to package @tanstack/eslint-plugin-query. Could You make it public? Bug is related to access in nested code of queryFn which doesn't trigger exhaustive-deps error. Attached examples of error and proper detection....
No description
metropolitan-bronze
metropolitan-bronze2/1/2024

Typescript and conditional select

Hi, So I want to have a query ```` const useGetItems = (id: string, select?: (data: ViewsType) => void) => {...
other-emerald
other-emerald2/1/2024

[TS Error] Can't export useQuery result

I'm currently getting the following TS error which I can't really resolve when trying to export a useQuery result:
The inferred type of 'query' cannot be named without a reference to '../../node_modules/@tanstack/vue-query/build/modern/useQuery-CPqkvEsh'. This is likely not portable. A type annotation is necessary.ts(2742)
The inferred type of 'query' cannot be named without a reference to '../../node_modules/@tanstack/vue-query/build/modern/useQuery-CPqkvEsh'. This is likely not portable. A type annotation is necessary.ts(2742)
Code:...
like-gold
like-gold2/1/2024

unresponsive invalidateQuery()

So all my other invalidateQueries() functions run on the rest of my app except this one, so I hacked it a bit to get it to work by setting the "enabled" property. The query runs when I change tabs at the top but not after an image is uploaded "onSettled" to make the new image available in the "Select Images" modal. So I'm basically running it with a "onClick" when I open the "Select Images" modal. If anyone has any ideas let me know ๐Ÿ™‚ Could it be that the modal on "Select Images" could be too f...
No description
modern-teal
modern-teal2/1/2024

Trouble with navigation after useMutation

Hi, I have a useMutation which gets called on an onSubmit to my login form. I call an endpoint on my server which returns a cookie with JWT token. All of this works correctly, however after I get the cookie i try to navigate to the /dashboard. It seems that if i do this right away the navigation does not work correctly but if i sleep for even a 100 ms it works (I have a before loader on the dashboard page that checks for the cookie being present). I'm guessing the cookies arent being set right away, and that a 100ms delay is enough for it to work but I'm not sure. I would really appreciate any help this is my first time working with TanStack. ``` const mutation = useMutation({...
rare-sapphire
rare-sapphire1/31/2024

What is the best way to paginate my queries (limit/offset on db) using tanstack table and query

I have a Node aplication on the back-end doing raw SQL and a React appliction on the front-end using tanstack table and tanstack query. if anyone has some tips or code that would help it would be apreciated
eastern-cyan
eastern-cyan1/31/2024

Trigger useQueries fnc in onSuccess of other func, but queryOptions fnc has diff queryKey

` export const useFetchDataScreen = (id:number):any => {
const assignDataFn = (id: number) => { return queryOptions({ queryKey: ['assignKey',id],...
fair-rose
fair-rose1/31/2024

can use only 2 args on useQuery()

Hi I canโ€™t use more than 2 arguments when invoking useQuery with options (keepPreviousData) Error : no overload match this call...
inland-turquoise
inland-turquoise1/30/2024

How to know if a state has changed from another component using useEffect

Details of my question are provided below: https://stackoverflow.com/questions/77903315/how-to-know-if-the-state-in-react-query-has-changed-from-another-component-using Note that it's not the same case of mine, but it's something very relative....