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

exotic-emerald
exotic-emerald10/26/2022

If staleTime set my data isn't refetched even the queryKey array changes.

When offset state is changed my query isn't refetched ``` const { data, status } = useQuery<PaginatedData<never>>( [url, offset],...
stormy-gold
stormy-gold10/26/2022

useQueries with already created hooks?

I created some hooks to use in my components: ```tsx export function useSaStates() { return useQuery(keys.saStates.queryKey, fetchSaStates, {}); }...
stormy-gold
stormy-gold10/25/2022

Query for data after Opening Dropdown?

Does it make sense to query for the data after opening a dropdown, or would it just make sense for the data to be queried on mount?
dependent-tan
dependent-tan10/25/2022

Calling resetQueries does not refetch with initial queryFn

There is a case where for the same query key by default I want to fetch one API, but when doing some action, refetch with some other API. To do that I use one useQuery hook to query and fetch the data. But on one a button click, I call queryClient.fetchQuery with the same queryKey and a different queryFn. Later I want to reset the query by calling queryClient.resetQueries to refetch again with the initial API, but the one previously used in queryClient.fetchQuery is called again. Here's a codesandbox link: https://codesandbox.io/s/react-query-reset-to-initial-queryfn-r84n9i?file=/src/queries.ts:615-625...
rising-crimson
rising-crimson10/25/2022

Turning off query retries does not work during tests

I am trying to set the query retries to false for my tests using Jest / RTL, I was reading https://tkdodo.eu/blog/testing-react-query It says specifying the options to: ```...
molecular-blue
molecular-blue10/24/2022

Can't get query data

I've constructed a query key for a paginated list with filters and sorting like this: ``` const useProducts = (currentPage = 1, activeFilters, activeSorting) => { return useQuery(['products', currentPage, activeFilters, activeSorting], {...
rising-crimson
rising-crimson10/23/2022

mutation callback not running if the component unmounts

Why is this? Is this a technically limitation or a design choice? What is the rationale for this?
quickest-silver
quickest-silver10/23/2022

setQueriesData not updating the cached data.

I have a mutation that updates data of a user. ``` export const useUpdateUser = (userID: string | undefined, userData: UserData) => { const navigate = useNavigate();...
conscious-sapphire
conscious-sapphire10/22/2022

How to mutate a function in callback while google auth react?

Hi everyone, can somebody help me. I'm using tanstack library and how can i mutate function on callback on social auth like google etc. I want to send the data when user sign-in then hit the mutate function.
like-gold
like-gold10/21/2022

TanStack React Query context on micro frontends

Hi! I'm currently working on a micro frontend project with each front end having its own instance of react query. I'm having some issues on a project related to cache invalidation and this seems related to the nature of having multiple instances on the same window. Reading the docs I understand that I should create a context to use and 'isolate' the instance on a project. My question is:...
No description
reduced-jade
reduced-jade10/20/2022

Clearing information on logging off.

Hello. I am using useQuery in a react application. How do I reset everything including error states and such? I want to add that to a logout function.
quickest-silver
quickest-silver10/20/2022

Which Query to stale?

I have 2 hooks. 1 fetches the employers, the other manipulates the data. All I care about is that the data is fetched on mount. No other fetches are required. Do I set the hook that manipulates the data with the stale time (useFetchEmployersQuery) as that is the hook that I am using in my component and mapping through the data returned. ```...
metropolitan-bronze
metropolitan-bronze10/20/2022

persistQueryClient for Offline Mode

Has anyone tried to use the persist query client plugin to implement an offline mode in a react native project?. I'm a little confused on how to use persistQueryClientSuscribe and persistQueryClientRestore so when the phone detects no services suggest to the user to activate Offline Mode, then hydrate with the persisted client. More details in this discussion that I opened: https://github.com/TanStack/query/discussions/4342...
harsh-harlequin
harsh-harlequin10/19/2022

Simple Example does not work

Simple example: https://tanstack.com/query/v4/docs/examples/react/simple I'm using typescript and redux. I had to make a couple changes, but here's the file: ```ts...
sensitive-blue
sensitive-blue10/19/2022

Keep data & error while refetch is loading

Hello! I'm trying to utilize the refetchInterval to poll on an endpoint, and utilize the data & error in the template. However it seems like whenever a refetch is initiated, the data and error props from the useQuery call are cleared until loading is complete, which results in the content blinking out for a short time. Is there a way to wait to update those until after the new fetch resolves?
rising-crimson
rising-crimson10/19/2022

Local-only fields; similar to apollo

Wondering if we can do the same as apollo local-only field with react-query? i.e: https://www.apollographql.com/docs/react/local-state/managing-state-with-field-policies/
correct-apricot
correct-apricot10/19/2022

what are the main benefits to upgrading to 4.x from 3.x?

what are the main benefits to upgrading to 4.x from 3.x?
exotic-emerald
exotic-emerald10/19/2022

Synchronizing Client-state with Server-state

Hello I have a problem with synchronizing a list of data with my own client state. The scenario is: I have a list of data coming from a useQuery hook and I have a client-state which is a hashmap/object of the selected IDs coming from the server(useQuery hook). The main problem for this is that the list of data is paginated so if i change pages the data refreshes....
deep-jade
deep-jade10/19/2022

graphQL - ReactQuery

good afternoon friends, I have a good doubt and I have really gone around and I have not been able to solve I have created a reactquery client with graphQL, I import it, but when I do the query I don't know where to place the variable or how to make it show me the data I need, I get a 401 error...
No description
adverse-sapphire
adverse-sapphire10/19/2022

broadcastQueryClient

I saw it is still in beta is it going to stable soon? And also at which version of tanstack is broadcastQueryClient supported? Thanks for the help...