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

literary-plum
literary-plum1/19/2023

I currently have custom hooks for each query/mutation of mine. Not sure how to implement useQueries.

Hey there, so I have many custom hooks that are used throughout my application. My goal right now is to use a few of those custom hooks in a useGetInitialData hook and return a combined loading state to show the splash screen until this is complete. Here are a few examples of my queries and how I am planning on creating that useGetInitialData hook....
evident-indigo
evident-indigo1/19/2023

Does anyone have an example for using debounce with React query?

I am using Zustand to save the search term ``` const searchTerm = AutoCompleteStore.useSearch((state) => state.searchTerm); const updateTerm = React.useRef(AutoCompleteStore.useSearch((state) => state.updateTerm));...
conscious-sapphire
conscious-sapphire1/19/2023

Should i fetch my own database from the clientside? or is that dangerous? (im using pocketbase)

title i'm using a next app, so i dont really know when im supposed to fetch data using react-query...
xenial-black
xenial-black1/18/2023

Query Key disappearing NextJS DevTools

I'm building a NextJS app leveraging react-query. When I load a page, it looks like the query key loads, but then instantly disappears. My guess is this has something to do with the query client going away, but I can't figure out what would be causing that. https://gyazo.com/98a07d34919ee4bb7ece7cfe67f4c20e...
correct-apricot
correct-apricot1/18/2023

error saying no queryclient set

My code has a main.jsx and an app.jsx. When I try to move the queryclient initialization into main.jsx so that app.jsx can use it in a useEffect hook, i get an error saying no queryclient set.
in my app.jsx i have a ReactDOM.render call that contains the <App /> which is surrounded by <QueryClientProvider>. how would i fix this? or does someone have an example of a main.jsx that renders an App that will have access to a QueryClientProvider...
genetic-orange
genetic-orange1/18/2023

Should we care about memory optimization when not using SSR?

Like, can the object React Query stores ever get big enough that the tab might end up using a ton of ram? If so, how do we prevent it?
quickest-silver
quickest-silver1/18/2023

Calling refetch but with different url parameters?

Hello, I want to call 'refetch' on a useQuery, but with a variation of url parameters. Use case: I have a set of buttons, which I want to make a GET call with slight variations, using the same useQuery for convenience. How can I pass these parameters to the query function?...
fascinating-indigo
fascinating-indigo1/18/2023

mutationFn is optional

Why is mutationFn optional in useMutation hook? Docs say it's required. I wonder if it is intentional or if it is just a bug in types.
No description
metropolitan-bronze
metropolitan-bronze1/18/2023

SSR prefetchQuery partial key

hi client side I have
useQuery(['foo', isAuth], fetcher)
useQuery(['foo', isAuth], fetcher)
...
stormy-gold
stormy-gold1/17/2023

React Query + Remix?

Hi! Anyone tried adding Tanstack to Remix? How did it work? Out of the box and easy or do you have to use some shenanigans?...
vicious-gold
vicious-gold1/17/2023

MutationKey null when using persistQueryClient

Hi, I am using persistQueryClient for caching mutations and queries when the user is offline. It works well for queries, but not for mutations. When using the custom hook useCreateTodo, I am getting a mutationKey of [null]. However, if I import the useMutation hook and use it like this: useMutation({mutationKey:['create-todo']}), it works when I restarts the app. I already have a mutationDefaults ``` queryClient.setMutationDefaults(['create-todo'], {...
sunny-green
sunny-green1/17/2023

Persister Timing

Hey! I noticed that theres about a 1 second delay between the state updating on the screen and the write being called to the persister. Any way to configure that to be faster? On logout I call queryClient.clear() and if the user happens to refresh the page fast enough, their auth cookie gets unset but the cache still holds the user information. Unlikely a user will see this, but just curious if I can do anything to fix it
other-emerald
other-emerald1/16/2023

setQueryData and structuralSharing

Hey! I have a question about structural sharing behavior when calling setQueryData manually. I have a query which I want to be updated only manually by setQueryData, so I set staleTime and cacheTime to Infinity. I also set structuralSharing to false, so my component always react to data changes after manual setQueryData call, even if updated data is exactly the same as previous one. The thing is that it doesn't. If new data is new object (made by spread operator), but is deeply equal to old data, data property returned from this query still has the same reference and it doesn't trigger useEffect(..., [data])....
literary-plum
literary-plum1/15/2023

add items in cache manually

Hello, I am dealing with a tree data structure, when the root is fetched, I want to add all individual nodes into the cache, so that when they are updated, only that one is updated
sunny-green
sunny-green1/15/2023

Run a function only once for all instances

Hello, I'm in an interesting predicament. I have a hook that looks something like this: ```ts export function useUser() {...
wise-white
wise-white1/14/2023

How to control the error when return undefined from a fetch?

I am getting this console error: Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ["Jockey"]. I am fetching without turn on the backend and I want to know how to control that error. ```...
wise-white
wise-white1/13/2023

How can I `useQueryClient` outside a Svelte component?

I'm using the excellent svelte-query – thanks so much Lachlan! I'd like to abstract my query functions and define them in .ts files away from my .svelte files. As part of this, I want to use onMutate and onSuccess functions to do optimistic updates etc, e.g.:...
quickest-silver
quickest-silver1/13/2023

Clear the data from useQuery?

(novice question, bear with me) I useQuery to fetch data from an API. The data is then displayed as-is on the screen. Great. Now I want to add a "Clear" button which clears the data. I can't seem to make it work. I tried the remove method returned by useQuery, but it doesn't work?...
rival-black
rival-black1/11/2023

Creating a mutation.

Hey everyone, I'm using react query and I'm stuck on creating a mutation to delete a message from my database using Prisma. I am very lost and any help is appreciated. Thanks!
No description