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

foreign-sapphire
foreign-sapphire6/28/2024

infinite loop

Does react query cache the results or error when the api returns an error?. React query custom hook gets called every time when the component is opened if the api is failed previously. Child component also calls the react query hook which I am using to get the data from parent react query call but because the api is failed child also calls api. the code looks like below example. This is causing infinite loop when there is an error customHook....
like-gold
like-gold6/28/2024

Fetching Queries in React Router Actions

I have an action on a route that makes a PUT request and then attempts to fetch a query. The query has keys which are dependent on state variables. Is there a way to update the query by only passing in a constant string instead of needing to pass in all the keys?
deep-jade
deep-jade6/28/2024

React query in typescript strict mode

Hi everyone, I am working in a company where we recently updated typescript in strict mode, so it means the strictNullCheck value will be activated. So now, if I am writing code like this, typescript will raise an error:...
foreign-sapphire
foreign-sapphire6/28/2024

Possible to persist queries on a per query basis?

I have an expensive query that I want to persist to local storage. It seems I will have to create a persister using createSyncStoragePersister and then add a <Provider> in the react context. But I want it to be saved to localstorage for only a specific query. How can I achieve this?
stormy-gold
stormy-gold6/27/2024

Query set default cacheTime

Hello, I'm trying to set the staleTime and cacheTime to infinity in the queryClient default options but the typescript is giving me a warning that I can't set the cacheTime within defualtoptions -> queries (staleTime can be set there fine). Am I missing something? thanks! ```export const queryClient = new QueryClient({...
unwilling-turquoise
unwilling-turquoise6/27/2024

v5 codemod does not work with query key variables outside the file

The remove-overloads codemod isn't working for all of my queries, which look like this:
return useQuery(queryKeys.globalApy, handleFetchApy)
return useQuery(queryKeys.globalApy, handleFetchApy)
...
rare-sapphire
rare-sapphire6/26/2024

infiniteQueryBehavior :: adding removeEventListener of the signal

Hi, i was studying react-query code and at infiniteQueryBehavior.ts i saw you attach a listener to the signal ```ts const addSignalProperty = (object: unknown) => { Object.defineProperty(object, 'signal', { enumerable: true,...
genetic-orange
genetic-orange6/26/2024

setQueryData with single signature.

Any interest having setQueryData updated to support a single signature? Would be happy to submit a pull request. I understand that setQueryData doesn't require many overloads, but perhaps there is a desire for conformity with the push towards a single object as an argument....
foreign-sapphire
foreign-sapphire6/26/2024

`data` becomes undefined / stale data for a second

I am using react-query like so. I am noticing that when I change the value of page via client state, the data returned by the useQuery reverts back to initialData while the fetch happens and then gets populated with the new data. It results in incorrect data being shown for the duration of the fetch (half a second). How can I prevent this?...
No description
rare-sapphire
rare-sapphire6/25/2024

Feedback on useQueryStream Hook for Observable Integration with React Query

I’m reaching out for some guidance to validate an idea we’ve been tinkering with—creating a custom hook called useQueryStream to handle Observables with React Query. We know you’ve mentioned before that streaming data flows aren’t officially supported, but we think our situation might be a bit different, and we’d love to get your take on it. We’d really appreciate any feedback you can give us on this approach. Thanks Marco ...
quickest-silver
quickest-silver6/25/2024

Specify queryKeyHashFn for queryClient.setQueryData()

It doesn't look like I can set a custom query key serializer with queryClient.setQueryData() https://tanstack.com/query/latest/docs/reference/QueryClient/#queryclientsetquerydata I see that the default options are used, and this is leading me to suggest users of the integration I'm writing to use this global settings. I'm wondering if this is a philosophical thing and I should try to move toward more simply serializeable query keys or if it would make sense to expose this and I should open a PR....
rival-black
rival-black6/24/2024

how to pass arguments to refetch fuction of useQuerry

I have function in my react native app which gets user latitude and longitude. Executing this function using useEffect. If i get location I want to fetch the data based on location( latitude and longitude ) otherwise want to show fallback component. i disable the query to run automatically by making enable=false. Now how should I pass the location with refetch function to fetch the data....
equal-aqua
equal-aqua6/24/2024

Uncaught error on mutation

Hi! I'm trying to catch rejected promise in mutation (onError) . But I get Uncaught error in promise. Unless I wrap await handleCreateGeneral(formData) with try/catch. ...
No description
fair-rose
fair-rose6/23/2024

Is it better to avoid calling `useQuery` many times? (i.e. inside a component that's in a loop)

I know that tanstack query de-dupes the request, but I would like to know if there are any obvious performance problems that may arise from calling the same query multiple times (i.e. n-sized list), as opposed to "lifting it up" to a parent component and passing the query as a prop/context
eastern-cyan
eastern-cyan6/21/2024

How can I remove the InfiniteData wrapper from the TData type

I am creating an infinteQuery and using a selector to flatten and transform the data. The query works as expected but typescript is complaining because (I believe) the TData type wraps the response type with InfiniteData. Doesn't seem to make a difference whether I leave it to infer or explicitly set the types. Thanks!...
stormy-gold
stormy-gold6/20/2024

can you break down `cancelQueries` to me?

I did not understand this part. I am using optimistic updates but there are no fetches being made during the onMutate callback call while using useMutation. I do not understand what is supposed to happen if I do not use cancelQueries in onMutate like the docs suggest 🤔
No description
national-gold
national-gold6/20/2024

External devtool cannot update component

Hey guys, I'm using the external devtool from this repo: https://github.com/LovesWorking/react-query-external-sync/ But at the moment I have both the debugger and a query on my app, it throw me the error:...
quickest-silver
quickest-silver6/20/2024

Can I make isFetching true after 500 milliseconds ?

isFetching is useful for show/hide loading UI during fetching but sometimes API response is too quick so the loading UI is displayed and disappeared very fast. It looks like glitchy. So I wonder if I can have an option to make isFetching true after a certain milliseconds?...
adverse-sapphire
adverse-sapphire6/20/2024

Layout component fetching useQuery and child component

Heyo, super happy that Tanstack exists, I'm still learning it. I have a _layout route component in tanstack that uses a query to fetch data and then for the child component I want to use the same query to use the cached data. ...
No description
dependent-tan
dependent-tan6/19/2024

useFocusNotifyOnChangeProps is not fresh after re-focus

Hello! In react native I have a screen where I load data with react-query. When it's out of focus I would like to not refresh the data. I checked the useFocusNotifyOnChangeProps as docs said, it works well but something is missing. ...