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

equal-aqua
equal-aqua8/10/2023

is react query a state management library like recoil? what's the difference?

new to the ecosystem & want to understand the differences.
flat-fuchsia
flat-fuchsia8/9/2023

When my app loads and caches a certain amount of data becomes slow or crash.

Hello everyone; I am using react-query@4.29.3. When my app loads and caches a certain amount of data, it becomes slow or may even crash. it improved slightly when I set 'refetchOnWindowFocus' to false, but the issue might still occur when it caches a larger amount of data. does anyone know how to resolve this issue?
fair-rose
fair-rose8/9/2023

onError deprecation

I noticed, that onError is marked as deprecated and I was wondering what would be the alternative? When using Error Boundaries this would lead in rendering a complete different component instead of being able to handle errors within my component containing the query. Or should I catch any errors in my query function and then set somehow the error object in the query?...
fascinating-indigo
fascinating-indigo8/8/2023

Testing Component that uses UseQuery hook

Hello ! I don't know if I'm following the right logic on this, do not hesitate to tell me i'm wrong. I have a component that uses the data from a custom useQuery to conditionally render the content of my page. I want to test the different outputs of my component which depends on the result of my useQuery....
deep-jade
deep-jade8/7/2023

Pagination - show loader

Im using useQuery for paginated data - i have keepPreviousData:true - to make my pagination not disappear while changing pages. I would like to show loader state only when there is no cached queryKey. For example: 1.Initial list loading - im using isLoading to show only spinner 2.First page loaded, Im clicking on page no 2. 3.Data for page no 2 is loading now. IsLoading flag will be false, because of keepPreviousData: true. My pagination is not disappearing, but I want to make my list of data disappear and show there only loader. 4.Im clicking back to page 1 - data is not stale yet, so there should be no any loader - just instant switch between pages....
like-gold
like-gold8/7/2023

Querying Behavior with PersistQueryClientProvider: Does useIsRestoring Impact useQuery Internally?

As we prepare to implement the PersistQueryClientProvider in our application, we're curious about the useIsRestoring feature. Specifically, we want to understand whether it affects the internal behavior of useQuery and if we need to address any use-cases where API calls should not be made until the restoration process is complete. Any insights or experiences related to this would be appreciated!
stormy-gold
stormy-gold8/7/2023

Why I need preFetch ?

As my understanding, if I can use preFetch , that means I also can use useQuery to fetch data ? If both of them have same functions keys and params. I think one of the benefit is preFetch won't return value, so we don't need to save it in variable first. May I correct...
stormy-gold
stormy-gold8/6/2023

fetch qurey onOPen in select Box

I have one doubt. I am fetching a post API request using React Query. In the API, I have to send IDs of data as body params. I am showing the API data in a dropdown menu. I want to handle that if the dropdown is open, then only data will fetch. <Select onOpen={() => {...
afraid-scarlet
afraid-scarlet8/5/2023

React Query with Conjunction of React Table

I am using both of this packages in a long time, for some time I noticed that when the 'query' fetches for a new data (for example when a user leaves to scope of the browser and then returns) the query data which is immediately transfers to the table resulting in a re-render, which basically means that the table loses is state - that resulting the problem, that if a user was one page 2 for example after the re-fetching the site will flicker and the user will be one page 1. What could I do to solve this issue?...
correct-apricot
correct-apricot8/5/2023

Invalidate query with new variables

Hello there, i have a problem with invalidating query. Currently i have userQuery. Afterwards i have jobsQuery with variables from userQuery. It fetches good but when i update user using mutation and want to invalidate jobsQuery, it runs with the previous variables from user (not with the new ones). Is there any way i could pass the new variables to jobsQuery? When i do refetch manually it refetches with new variables. Thank you for any ideas. Here is example of my code:...
passive-yellow
passive-yellow8/4/2023

Array as queryKey

What happens here: ```tsx queryKey: [ tradeOperation, 'nftsForTrading',...
optimistic-gold
optimistic-gold8/3/2023

isError behaves differently depending on whether initialData is present (when refetching)

I'm trying to wrap my head around the behavior I'm seeing and scouring the docs hasn't fully clarified my understanding. For some context: I want to show a "retry" button if a query errors AND while it's refetching (the button should remain until the query succeeds). There are 2 different cases I need to handle: one with initialData and one without....
ratty-blush
ratty-blush8/3/2023

useInfiniteQuery Pagination

Hi, I'm implementing an inifinte list of items for the user, and when the user deletes one I want to refetch all pages but it's not working. Let me explain it after showing some code. function useUserWatchlist({ userId, pageNumber = 1,...
conscious-sapphire
conscious-sapphire8/2/2023

How to use a persister with a cacheTime of zero?

I tried explicitly setting the cacheTime to 0 in the creation of the QueryClient but every time i refresh the page i see all queries being stored in local storage. I want to not do that and explicitly opt in to persisting via localstorage on a query by query basis. For example, i have an endpoint that takes a few seconds to resolve with data and that data is pretty static. I want to persist this to localStorage and cache it for 30 minutes. What QueryClient options should i be using? what should my useQuery look like for that scenario? Current code:...
fascinating-indigo
fascinating-indigo8/2/2023

Is there a way to set isLoading state manually (using query key)?

I am using websocket with react query. I found TkDodo's awesome blog on this I want to follow the approach in which I receive 2 things from backend in one WS message:- 1. query key to do queryClient.setQueriesData() 2. data payload...
foreign-sapphire
foreign-sapphire8/1/2023

Is `data` always meant to be possibly undefined

Even when using even when using keepPreviousData and placeholderData? ```ts const { data } = useQuery({ queryKey: taskBoardQueries.weeklyHours({ start }).queryKey,...
generous-apricot
generous-apricot8/1/2023

How to implement a infinite scroll which uses websocket updates

Hi, Im implementing a chat conversation list(facebook chat) in RQ. In this conversation list I want - Infinite scroll to load previous messages - Websockets will send updates about new messages, it should be updated in real-time in the UI without re-fetch(updating query data)...
wise-white
wise-white8/1/2023

Are queryKey deeply compared ?

Hello, Let's say I want a <UserInfo/> component that can either accept a user Id or a user Email : <UserInfo id={1} /> or <UserInfo email="simone@corp.com" /> This leads to props typed like this :...
helpful-purple
helpful-purple8/1/2023

Solid-Query getQueryState result isn't reactive

I'm calling queryClient.getQueryState(['current-user'])?.status === 'error' in a Match statement but despite the query erroring, the conditional never renders In order to account for this I hacked it into an effect ``` let timerId: number | undefined; createEffect(() => { timerId = setInterval(() => {...
eastern-cyan
eastern-cyan7/31/2023

is there an enabled flag on `useSuspenseQuery` in v5 beta?

how can I skip running a query