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

inland-turquoise
inland-turquoise8/25/2023

Understanding Query Keys

Good day, people! I need help in understanding query keys in general for invalidation and caching. I have a query that fetches all the posts for your timeline in a social media app. A Post has {poster, comments, likes, postId} ```ts const query = useQuery({ queryKey: ['posts'],...
metropolitan-bronze
metropolitan-bronze8/24/2023

When mutation should end up with success?

Im returning undefined from mutationFn and there is still success, also fetch response of 404 status for example does not end up with error, always is success.
harsh-harlequin
harsh-harlequin8/24/2023

UI doesn't re-render after mutation

for some reason the UI doesn't re-render after I make a mutation such as update or delete despite the data does change when I use watch ``` const [todos, setTodos] = useState(useTodoStore); //watch todos useEffect(() => {...
absent-sapphire
absent-sapphire8/23/2023

Slow navigation on Expo app with react-query

I have a screen from my Expo app where I use my own hooks that use react-query's useQuery and useInfiniteQuery hooks. Example: File api.ts...
inland-turquoise
inland-turquoise8/23/2023

Is useEffect the best way to handle changes in data?

I have data that can change on the server and when it does I want certain things to happen in the app (such as opening a popup). I am currently handling this like this: ```typescript const fundingStatus = useFundingStatus()...
equal-aqua
equal-aqua8/23/2023

typesafe dynamic parallel queries ?

hi how to make it typesafe anyone kindly guide
No description
harsh-harlequin
harsh-harlequin8/23/2023

NextJS doesn't re-render on mutate

First time trying out zustand and react query for nextjs 13. The UI just doesn't seem to update after I make the query https://www.reddit.com/r/nextjs/comments/15z0d1z/unable_to_delete_item_from_zustand_store_with/...
sensitive-blue
sensitive-blue8/23/2023

What is the best way to refetch with dependent queries

is there a way to also refetch the dependent query? currently, when i refetch for example the
userQuery
userQuery
id does not refetch the projects. ``` const { data: user, refetch } = useQuery({ queryKey: ['user', email],...
harsh-harlequin
harsh-harlequin8/22/2023

Optimistic updates with sorted lists

For a list of todos sorted by due date, what is the best way to handle optimistic updates for a new to do? https://tkdodo.eu/blog/mastering-mutations-in-react-query mentions it as one of those cases where things can get complex fairly quickly but it is a required feature for what I'm building.. My guess is that you add it to the cache and run a local sort. This seems fine....? Am I missing something. ...
sunny-green
sunny-green8/22/2023

eager loading query with remix

im using remix and I want to use react query for everything instead of loaders because loaders block the navigation. Is there a way I can make the query load faster in initial load? for now it waits until everything hydrated then only then it fetches the data. can I maybe make it run in parralel with js after the html load? is it possible?
harsh-harlequin
harsh-harlequin8/22/2023

Not sure how to split API calls to optimize for optimistic updates

My web app has tasks of 2 types - 1. projects tasks (which are part of a project, and in the project part of a stage) 2. individual tasks (which are standalone) I have a route where I can see 'My Tasks' from both of these sources. Right now I have an api which gives all my tasks from both these sources. When I click on a task, it opens a panel where I have another api which gives me that task with all its attributes. ...
dependent-tan
dependent-tan8/22/2023

Any gotchas with combining two dehydrated query clients?

I’ve got some application level queries that I’d like to "cache" for the entire app (Next.js app FWIW). My thought was to combine a page’s dehydrated state with another one done at the root of the application. Is this advised? Any OOTB methods to combine caches? Better ideas to accomplish this?
multiple-amethyst
multiple-amethyst8/22/2023

Is there a difference between retry=`false` vs `0`?

I'm getting a wired behaviour that my queries retry unexpectedly when retry=0. Just to make sure, is there a difference between retry=0 vs retry=false in useQuery?
wise-white
wise-white8/22/2023

Mutation Stuck in "isLoading"

I have a mutation that performs a login when they press the button. If it errors I do stuff and if it succeeds I push them on to the next step or whatever. I have my login mutation, which seems to constantly be stuck in a loading state. I have verified that the login errors. I go to the devtools and I see it error, 400. Axios throws an error in console, request failed with status code 400, invalid credentials. ...
stormy-gold
stormy-gold8/21/2023

Pass information from onMutate to mutationFn

Is it possible to access the data returned by the onMutate function inside of the mutationFn function? Context: I am using the onMutate function to do optimistic updates. While doing so, I append a little information to my object, which I would like to use when syncing with the server inside of the mutationFn function....
deep-jade
deep-jade8/21/2023

Cache problem with react-query v4

So couple days ago i found some problems, like wrong data in cache I have api, its gets me [{alias:'one'}, {alias:'two'}] Api working fine, but after useQuery() or prefetchQuery() im getting [{alias:'one'}, {alias:'two'}, {alias: '3'}, ... some elements that not in api response] So i was thinking, can it have some problems with memory sharing and docker?...
deep-jade
deep-jade8/21/2023

onSuccess Alternative for react query v5

I use onSuccess callback in v4 for example I send notif when It is fired but How could I do this callback?
xenial-black
xenial-black8/21/2023

Persisting queries containing dates

Has anyone tackled the issue of deserializing dates contained in queries while using PersistQueryClientProvider? I understand this is not trivial since JSON does not have a type for Date, nonetheless it seems a common use case and I could not find any reference in the docs or previous questions. I just started using the provider with React Native and the async storage persister: the app is immediately usable in offline mode, which I like, but all dates are broken! Dates are currently received from the API in ISO 8601 format, but they are casted to Date by our autogenerated TS API client, which gets called into the TanStack query callbacks: any suggestion to obtain automatic rehydration when data is read from the storage?...
stormy-gold
stormy-gold8/20/2023

React-query for session management

Hello all, a while back there was a ticket about next-auth not working properly with react-query(suspense mode), however I really like the way it handles session as for example if you are logged in tab one and open another tab(2) once you are logged out in one it logs you out on all of them, is this behavior something possible with react-query, I was messing around and thought maybe using some stale time or window refocus would be possible, my inital thought would be something like this, you w...
adverse-sapphire
adverse-sapphire8/19/2023

initialData doesn't work

I tried to make code using initialData, but none of the output comes out even the key doesn't appear in react-query-dev-tool
No description