1,860 questions
-1
votes
0
answers
51
views
Live Data in React Tanstack Query: streamedQuery vs Auto Refetching [closed]
In my React application, I want to implement a page that shows live data, such as the current status of a camera (on/off) and images taken by the camera, triggered by different events.
I am using ...
0
votes
2
answers
85
views
React Query Server Side Rendering
I have been using react query and next.js , I need to know how can achieve server side rendering using react query, I can achieve with this using normal fetch or axios in the server side components, ...
0
votes
1
answer
33
views
Unable to display selected option label when fetching options through an API with limit
I have a functionality where I have an id as a URL search param.
So I get the id and send it to a Custom Select, which then filters the options that I send to it as a prop that I have fetched through ...
0
votes
1
answer
85
views
How can I have a delay until useQuery/refetch have returned the data
I am developping an iOs/Android App with React Narive.
I am using useQuery (TanStack Query v5) to send the username and an hashed password to my database and it return the user ID if the email/...
0
votes
0
answers
38
views
Can a Tanstack query function return the results of another query function?
We're in an awkward situation needing to consume an API endpoint that is not built correctly. It returns pages of (unsortable) records without revealing beforehand how many pages there are in total.
...
0
votes
1
answer
164
views
Can Tanstack/React Query handle dynamic parallel queries that are computed based on earlier queries?
I see that Tanstack Query supports parallel queries in a certain way that is dynamic, per this page: https://tanstack.com/query/latest/docs/framework/react/guides/parallel-queries#:~:text=each%...
-1
votes
2
answers
117
views
React hook form + react query. Sync defaultValues on refetch without clobbering dirty fields, and hard-reset after submit [closed]
Context
I’m using React Hook Form together with React Query. The parent component fetches data with a query, derives defaultValues, and passes them into the form.
Parent component:
export const ...
0
votes
0
answers
73
views
How to refetch react openAI react query queries
I am working on a react native app that is using openapi-react-query in order to enforce the type safety across backend and mobile, my struggle is how to refetch queries (in a component other than the ...
2
votes
1
answer
185
views
How do I distinguish between query and mutation in runtime?
I'm using Typescript 5, Next.js 15, tRPC 11, React Query 5 and React 19.
How can I programmatically differentiate between DecoratedMutation<...> and DecoratedQuery<...>?
I have tried:
...
0
votes
1
answer
137
views
RefetchInterval, and QueryKey Changing, will this cause two network requests?
Really need some help understanding the nuances and effects of how refetchInterval, and queryKeys interact with each other.
Currently, I have a UI that is stuck on loading state. I suspect it is ...
0
votes
0
answers
29
views
Pausing refetchInterval, is it possible? Sometimes, response takes longer than interval. This leads to stacked calls [duplicate]
I'm using React query, and my query client options look like the below:
export const DEFAULT_POLL_INTERVAL = 2500;
const queryClient = (pollingEnabled?: boolean) =>
new QueryClient({
...
0
votes
2
answers
52
views
How to make react-query wait till input data used in request is resolved with other API call?
I am using tanstack-query and have dependent queries to do:
const { resourceId } = useGetResourceId(); // resourceId: number | null
const { data, loading, error } = useGetResourceData(resourceId);
...
0
votes
1
answer
203
views
Put query into isPlaceholderData with QueryClient methods (while using keepPreviousData)
I have a query that uses placeholderData: keepPreviousData. This means the
query is in a hard loading state, with no placeholder data, on initial mount.
Then, when the queryKey changes, it goes into a ...
0
votes
1
answer
73
views
React-query isRefetching is triger loader in RefreshControl at first mount screen
In my react-native project, I use tanstack react-query: https://tanstack.com/query/latest/docs/framework/solid/reference/useQuery#isrefetching-boolean
Why is isRefetching executed if I don't call ...
1
vote
1
answer
98
views
How can I handle 404 error when prefetching data with usePrefetchQuery?
I use an infinite list for which I prefetch data on the app startup. Everything works great except for when I hit 404 error if, for example, I manually change the url to a wrong one. Then the whole ...
0
votes
2
answers
120
views
How to refetch from a client component with useQuery
I have a client component that fetches the list of project and a dialog box that creates a project but I cant update the project list unless I have to do a manual refresh on the browser.
The flow is:
...
0
votes
0
answers
23
views
Firebase set with merge of partial object followed by getDocFromServer returns that partial object
I'm using React Native/Typescript/Expo and Firebase (Auth, Firestore). I'm testing in web. I'm using Tanstack Query between my app and Firebase.
I'm running into an issue where, when upserting a user ...
4
votes
0
answers
263
views
How to test useSuspenseQuery hook
Recently I read about new hook useSuspenseQuery provided in @tanstack/react-query v5.
Previously I have used useQuery and have written unit tests on it.
I am trying to write unit tests on ...
0
votes
0
answers
146
views
How are you supposed to handle loading states for trpc (useQuery) calls in client components in Next?
I have a client component that calls for data via trpc. I extract isLoading from those useQuery calls and then I want to display a loading skeleton while the data is loading.
However, when I follow ...
0
votes
0
answers
42
views
React query v4 optimistic updates
I have two media hide and unhide, I am using optimistic update approach from react query
It works smoothly, the setup of my react is list of checkbox, 1 list for hidden and 1 list for non-hidden items....
-1
votes
1
answer
61
views
Login and logout create and destroy the JWT but the UI doesn't update
I created an Auth context with tanstack query with login, logout, registration functions I can use in the respectively pages to handle the authentication.
But everytime I either login or logout the ...
1
vote
0
answers
21
views
Navigation issue with multi step react form with react context updates
I'm building a multi-step order form using React, react-hook-form, and react-query. Initially, there are three visible steps: customer information, product selection, and order summary. Depending on ...
1
vote
1
answer
513
views
React query useSuspenseQuery causes twice render when using state-changing component
I am using useSuspenseQuery from React Query to fetch data in a React app. While the API is fetching, I want to show a loading state using <Suspense fallback="Loading" />.
The issue ...
0
votes
0
answers
23
views
Infinite query fetchNextPage modifies first page's data
I have a mutation where I append a comment to the first page (pages[0]). In my onMutate, I cancel any ongoing refetches (if we're not fetching a subsequent page) and then refetch in onSettled
Mutation:...
0
votes
0
answers
59
views
Update multiple items by id use tanstack query
I need to update all formulas in cache that use the same raw ingredient after it has been changed using tanstack query.
In Tanstack Query I newbie
My implementation but this code does not always work ...
0
votes
0
answers
44
views
"Error: No QueryClient set" when using TanStack Query in a component package across repositories in Next.js
I have a Next.js application (main-app) that imports and uses UI components (widgets) and API hooks from a separate repository (abc-widgets).
These widgets internally use API hooks that rely on ...
0
votes
0
answers
35
views
When using react-query, how to write unit tests for the scenario of Dependent Queries?
how to write unit tests for useUpdateTodo hook without mock useGetUserId
// Get the user
const useGetUserId = ()=>{
const { data: user } = useQuery({
queryKey: ['user', email],
queryFn: ...
1
vote
1
answer
102
views
How to handle for a request that takes to long to download content using useQuery from React Query?
I'm using useQuery function from React Query to fetch data in my React application. However, I'm encountering an issue where some requests take too long to download content (about a minute).
Here's a ...
3
votes
0
answers
388
views
useInfiniteQuery fails on React Native with "observer.getCurrentResult is not a function" error in @tanstack/react-query ^5.66.3 or higher
When using useInfiniteQuery in React Native environments (Android and iOS), the app crashes with the error: "observer.getCurrentResult is not a function (it is undefined)". This error does ...
0
votes
1
answer
207
views
how to use React Query (TANStack) in next js server components?
A lot of people are saying that use React Query for efficient data retrieval. But to use useQuery hook I have to make every component "client component" then what would be the purpose of SSR ...
1
vote
1
answer
279
views
access token doesn't change on ky retry request
I am trying to pass my access token to requests made with ky and retry them on 401 error with an updated token. On retry the token updates but the requests themselves still have the old token. How do ...
1
vote
0
answers
104
views
Managing Refresh/Cancel functionality in AG Grid Infinite Row Model
While migrating from the client-side row model to the infinite row model, my team and I are attempting to preserve the functionality of our custom Refresh/Cancel button.
In the client-side row model, ...
0
votes
0
answers
92
views
Yarn workspaces monorepo cannot find React Query module
I have set up a react native monorepo using Yarn Workspaces. The goal would be to write one App as core, and the versions for different platforms would be siblings of core in the monorepo and would ...
0
votes
1
answer
288
views
Why is react-query invalidation bleeding across tabs?
I have 2 instances of storybook running an application locally. I have 2 tabs open on localhost:6006 and localhost:6007, and I log in as a different user on each.
I do things in 1 tab that ...
0
votes
1
answer
903
views
Canceling a react-query mutation
I have a mutation that comprises of a sequence of long-running actions:
useMutation({
mutationFn: async () => {
await firstTask()
await secondTask()
await thirdTask()
},
...
})
I ...
3
votes
2
answers
769
views
Handling two cache keys for the same data in react-query
I have a Project type in my app. I need to be able to access it via two separate async function:
getProductBySlug
getProductById
At the root of the page I use the URL to derive the slug and query ...
0
votes
1
answer
39
views
Infinite feed scroll jumps when setting overflow to scroll
I am using react-query for infinite loading feed and '@tanstack/react-virtual' for virtualization of the cards which are composed of mui elements. I want to keep my app height to 100vh so there's no ...
0
votes
1
answer
445
views
Next js react query v5 useSuspenseQuery, 401 unathorized
I want to use useSuspenseQuery along with next js so that I can take advantage of the built-in React feature.
But when using useSuspenseQuery, it gives an error img
query
const { data, isLoading } = ...
1
vote
1
answer
123
views
Does the refetch interval timer begin at the start of a request or after the request completes?
If refetchInterval is set to 10 seconds in useQuery, and a given request takes 2 seconds to complete, will the next request be initiated 10 seconds after the start of the previous request, or 10 ...
0
votes
2
answers
88
views
Flattening an array causes UI freeze
I have an app with cards. Cards are fetched with useInfiniteQuery from React Query. I fetch new card each time I reach the end of the list.
Backend sends offset and limit based responses of this ...
0
votes
1
answer
399
views
React Query in Expo wont refetch
I'm building an Expo React Native app using Expo Navigation (Stack Navigator) and React Query. When navigating between screens (e.g., from Home to Test screen and back), I need to refetch data when ...
0
votes
1
answer
649
views
Can I use TanStack Query as a replacement of client-side state managers such as Zustand or Redux?
Can I use TanStack Query with the below code example as a replacement of client-side state managers such as Zustand or Redux and therefore, have only one single state manager across the application?
...
0
votes
0
answers
219
views
@shopify/flash-list breaks when using a contentContainerStyle with percentage horizontal padding with an useInfiniteQuery
When using a list with infinite scrolling using
useInfiniteQuery
that has a
contentContainerStyle
with a percentage value for paddingHorizontal the list is not rendered at all.
Here is the List ...
0
votes
1
answer
69
views
How to trigger API call only when manual search, or page are changed in React Query?
I have search form, and i only want to call the api when selectedPage or resultsPerPage change or when user click on search after write some things in the form.
With this, the api is called when the ...
0
votes
1
answer
280
views
React-query v5 query data contains an empty object when using persistence
I've noticed that many users of my app get unexpected runtime errors because react-query (v5.64.2) query data contains an empty object (and my backend never returns empty objects). I've also noticed ...
1
vote
1
answer
87
views
ReactQuery invalidateQuery doesn't work, UI updated with optimistic updates but data is not re-fetched
I use optimistic updates for the UI and it works, but the data is not re-fetched. In the server terminal I see only a DELETE request. There should be a GET right after it
queryClient.js
import { ...
0
votes
0
answers
29
views
Tan Stack React Query Error: No Overload Matches This Call
I added the initialPageParam, and I'm still getting this error on my queryFn. I don't understand why I can't provide a () => void function when a QueryFunction<InfiniteScrollPost[], readonly ...
1
vote
1
answer
215
views
Why is my React component occasionally stuck in an infinite re-render loop?
I have a React project where I am using React Query and TanStack Table. Occasionally, my component enters an infinite re-render loop, and I can't figure out why. Sometimes it works perfectly fine, and ...
-2
votes
1
answer
152
views
Query Invalidation: why i have to refresh the page to get the results fetching the habitats or delete the habitat?
So this is the first part is from a component where i create new habitats using tanstack V5 im passing queryKey ['habitats']
const createHabitatMutation = useMutation({
mutationFn: habitatService....
-1
votes
1
answer
118
views
React Query changes behavior after 'useState' variable is updated
I have a very simple react application using React Query with two react components: App and BotConfig. I am experiencing React Query functions within a component change their behavior from working as ...