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

confidential-salmon
confidential-salmon2/14/2023

Use toggle to enable different useMutation call

I have a toggle button which gives true/false value in useState, then I have an ordinary useMutation call, then I want to write: ```js if (true){ call that useMutation func A } else {...
foreign-sapphire
foreign-sapphire2/13/2023

Will query-dev-tools and persistent stores become available for svelte-kit?

I was watching https://www.youtube.com/watch?v=SPPQm0dvEes from Jason and Dominik and was impressed with the power of react-query. I am using svelte-kit and implemented @tanstack/svelte-table and am now experimenting with @tanstack/svelte-query. First impression is very good but the dev-tools and the persistent stores would be very helpful. Any plans for this or am I missing something that is already there?
subsequent-cyan
subsequent-cyan2/13/2023

Trouble with session-cookie authentication

Hi, I'm trying to get authentication working and I'm not sure I'm going about this right. My backend uses JSESSIONID cookies. So POSTing a user/password to an /auth/login endpoint yields a 200 OK and sets the cookie. From then on withCredentials: true on axios ensures that the subsequent requests don't yield 401s (I'm skipping over CSRF etc as that's not a issue here). ...
afraid-scarlet
afraid-scarlet2/12/2023

isLoading with initalData

I tried to get ‘isLoading’ and ’status’ from useQuery hook and always I got false on isLoading and the status - “success” although it’s was first fetch. After some checks I found that because i define ‘initalData’ on querycllient cause to this problem. How I can set initial data to all queries and also get the isLoading status?...
extended-salmon
extended-salmon2/12/2023

file structure

hello i wanted to know opinionated file structures for RQ im a rtk query users wanted to jump in RQ but i want to know before a good structuring that can scale if you have repos,blogs, or just your opinions about it i would love that...
afraid-scarlet
afraid-scarlet2/12/2023

useMutation firing and has a response, but does NOT return in "data

I have not run across this before, but I have a mutation, ala. ``` export default function useRegister(source) { return useMutation(...
harsh-harlequin
harsh-harlequin2/12/2023

Sync between local state (in useReducer) and db for a form builder

I am building a form builder. Since it is a fairly complex data structure to store the form template state, I am using a reducer to store the local state so that updates can be made modularly. The initial state for this reducer is gotten from react-query. However, when there is an update to a field, I want it to update in the db onBlur (rather than a save button). I am not sure if what I'm doing makes sense - 1. When there is a change (let's say the name of the form for simplicity), I locally change the state of the input and onBlur I change the reducer state with a dispatch. 2. The dispatch also has a mutation which makes the api call to update the db. ...
relaxed-coral
relaxed-coral2/10/2023

Update Persister with New Data

Hey! My async storage has the option to notify me when the storage is updated from elsewhere (different tab for example). I was looking at the docs and I think I found this: https://tanstack.com/query/v4/docs/react/plugins/persistQueryClient#persisters but I'm not sure what exactly restoreClient does. Should I call that any time that my storage notifies me the local storage changed? The notification also includes the new data, can I just somehow pass that to react-query to save an extra read?...
solid-orange
solid-orange2/10/2023

useEffect for queries?

useEffect doesn't fire when data in a query changes. How can I make this work?
No description
metropolitan-bronze
metropolitan-bronze2/10/2023

ts error ?

kindly guide me how to fix this thankyou
No description
genetic-orange
genetic-orange2/9/2023

Cancel paused queries on component unmount

Use case : I go to a screen A while offline and then come back to previous screen B. When I come online I don't want fetch for screen A to happen in background. Basically, I want to cancel a query if the component in which it is present is unmounted. Passing signal in axios.get to cancel query works but only for idle queries. But for paused query it doesn't stop network request....
subsequent-cyan
subsequent-cyan2/9/2023

Wrapping QueryClientProvider

Hello, Is wrapping QueryClientProvider a bad practice ? I'm interested in doing this in order to be able to use React Router's useNavigate hook within both queryCache & mutationCache onError handlers in order to redirect globally on 401 errors and I can't do this if the QueryClient is defined outside of React... Cheers...
national-gold
national-gold2/9/2023

Fetches going off before login

I have a query that looks like this: ```js const { id, token, env } = useCredentials(); const { data } = useQuery( ["items", id, token, env],...
like-gold
like-gold2/9/2023

use result from query without triggering a new query

I have the following scenario in a react native app: I have a component that queries for a list of restaurants and display them in a list. I have a filter button that when pressed displays a filter screen that shows the list of all cuisines: indian, chinese, etc. for the user to filter restaurants by. The list of cuisines is derived from the result of the restaurants query, so I want to use the result of the restaurants query....
helpful-purple
helpful-purple2/9/2023

InvalidateQueries not refetching with dynamic key

I'm trying abstract away some boilerplate in our application. So, the queryKey is assigned by a prop in our case. The list view works great, and the delete action also. But when I want to refresh the list (after deleting), nothing happens. Query looks like:...
stormy-gold
stormy-gold2/8/2023

Blobs

Is it possible to cache blobs?
like-gold
like-gold2/8/2023

Updating query data without access to complete query key

Assume the following scenario: I have two screens: Screen1: queries server for restaurants and displays them in a list( favorited restaurants have a heart icon displayed in the ui) Screen2: displays a single restaurant where the user can toggle the favorite state ...
ambitious-aqua
ambitious-aqua2/8/2023

Create query for result returned from a mutation

I am using React-Query and Supabase to build a multi-step form. In the first step of the form performs an insert into a table and then returns the row. I want to cache this returned row but ensure that this row isn't duplicated if the same user wishes to fill out this form again. How would I achieve this? Apologies if I haven't articulated the issue clearly enough.
rival-black
rival-black2/8/2023

Is there a way on react-query to trigger all my fetch upon refresh?

after rigger fetch app can only trigger each fetch depends onFocus screen?