Questions tagged [tanstackreact-query]

use this tag for questions related to https://github.com/tanstack/query

tanstackreact query is async state management for JS/TS and related frameworks. For more details please check here

72 questions
3
votes
0 answers

How to keep refetching (refetch) `useQuery` even after the component unmounts?

I am using useQuery and its refetch option to download a file in the frontend. The download process is of two steps, and I am displaying the below notifications to the users: Download process is started, the file will automatically download once…
Manny
  • 134
  • 2
  • 15
2
votes
1 answer

React-query persist client with typescript error

I was trying to use the PersistQueryClientProvider, but it's throwing an error of type "declaring missing parameters on the queryClient". However, in the documentation, these parameters are stated as optional. Here are the errors: Type 'QueryClient'…
2
votes
0 answers

React Query refetchInterval not working, only calls API once

I had used refetchInterval before and it was very straightforward. For some reason I can't get it working anymore now. This code only calls the API only once. const { data, isFetching } = useQuery( ['test'], () =>…
Aximili
  • 28,626
  • 56
  • 157
  • 216
2
votes
0 answers

Next.js Failed to load static props (with react-query)

I saw in sentry that many users experience the error "Failed to load static props" but I don't know why, if I try to go to the same url it always works for me, Also the for the users I can see in the replay that the page seems to load with all the…
1
vote
0 answers

Is there simple way to call react hook from useInfiniteQuery callback?

I have a hook that pulls some data and does some other stuff: const search = useSearcher(...); Hook itself sends API requests and updates its search state as necessary - clears search state if search query is empty string, cancels requests, sets…
user2363676
  • 331
  • 2
  • 10
1
vote
0 answers

ImportError with '@tanstack/react-virtual' module: 'useVirtualizer' not exported?

I'm encountering an issue while using the @tanstack/react-virtual library in my React project. According to the documentation, I should be able to import and use the useVirtualizer function from this module. However, when I try to import it as shown…
1
vote
2 answers

React Query: How to configure React Query to retain data even when errors occur?

How can I configure React Query to retain data even when errors occur? This is my code but when there is error data would change to undefined Additionally, it appears that the onError method is deprecated in the latest version of React-Query Is…
Dvlpr
  • 1,439
  • 1
  • 11
  • 21
1
vote
1 answer

Re-rendering is not happening while using Tanstack query

I'm fetching the API using Tankstack query. This is the custom hook to fetch the data, import { useQuery } from "@tanstack/react-query"; import { ApiInstance } from "../axios/axios"; import { Endpoints } from "../endpoints/endpoints"; export const…
Santhosh
  • 31
  • 6
1
vote
1 answer

Getting the previous mutation of a todo object

I have a todo app, and I have an issue that I receive the old todo instead of the updated one. after saving a todo, I'm opening a modal with the todo info but instead of showing the updated todo, it's showing the previous todo. here is the modal…
noer
  • 35
  • 3
1
vote
0 answers

React Query v4 gives me Missing queryFn for queryKey when queryClient.setQueryData

I am continuously getting following error Missing queryFn for queryKey '["cocktail","favorites"]' Here is my implementation import { useQueryClient } from '@tanstack/react-query' interface ICocktailCardProps { cocktail: ICocktail mode:…
Janith Widarshana
  • 3,213
  • 9
  • 51
  • 73
1
vote
1 answer

How to invalidate cache initialData in react query/tanstack query?

I am using useQuery hook in TanStack Query (previously React Query) to cache data, in my case I config initialData depend on another hook useInfiniteQuery but when I am trying to invalidate useInfiniteQuery, cache from useQuery always immutate. In…
Epple
  • 640
  • 14
1
vote
1 answer

React query custom hook not propagating error state to component where it was called from

I use react-query in my project, and I got a bug in my custom hook where I use useMutation query. I have all my custom hooks for queries in the file useApiData and useUpdateCase is one of them: export const useUpdateCase = (caseId: number) => { …
Leff
  • 1,968
  • 24
  • 97
  • 201
1
vote
1 answer

how to type-safely pass an argument to useQuery from a previous request?

I have two custom hooks for using useQuery. The second hook depends on the result of the first While the first hook is being executed its data is undefined interface Props { id: number enabled: boolean | undefined } export const getFooQuery =…
qvazi
  • 53
  • 4
1
vote
2 answers

React-Query Fetches stale queries with expired access token

We are using react-query to fetch data from an API. For every api call there is a seperate hook with different query key but all of them are using same function callApi() which takes the api url as parameter to fetch data. Inside callAPI() hook we…
Faizan khan
  • 185
  • 1
  • 12
1
vote
1 answer

Why does the browser trigger a refetch of values in useQuery from TanStack when it is refocused?

I'm using the useQuery hook from the React Query library in my React application to fetch data from my server. However, I've noticed that whenever I switch away from the browser tab and then come back to it, the useQuery hook triggers a refetch of…
1
2 3 4 5