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
0
votes
1 answer

React-Query how to cancel polling on Button click

I have logic to stop the polling from within the react query refetchInterval: (data) => data?.status_code === 'SUCCESS' ? false : 5000 But how to stop the polling in some other component when a Button is clicked. I tried this but somehow the polling…
Dhruv Pandey
  • 482
  • 6
  • 18
0
votes
1 answer

React query doesn't sustain its cache after queryClient.setQueryData

React query doesn't sustain its cache after queryClient.setQueryData, also it's not working on defaultOptions like under. i am using react query developer tool and it show that that data get stored after API call but i saw a property gcTimeout: 23.…
0
votes
1 answer

Can't deal with POST request + StrictMode

I need to run a POST request only once when I enter the page, the purpose is to validate an user, depending on the response, different content will be shown on the page. I'm using react-query to do the request, here's the example: const { mutate } =…
0
votes
1 answer

Cannot clear query cache after error globally

I am using onError callback to show toast messsage globally. And I also want to clear all cache If user gets 401. But in error callback error and query parameters don't have any method to achieve this. How can I do it? const queryClient = useMemo( …
Furkan
  • 85
  • 1
  • 7
0
votes
0 answers

Next.js 13 API Route Returns 500 Error When Saving Image - Prisma and zod Validation

I'm working on a Next.js application where users can generate logos and save them to their account. When the user clicks the "Save Image" button, a POST request is made to an API route to save the image URL along with the user ID to a Prisma…
0
votes
0 answers

Invalidate query doesn't fetch fresh data

I have this simple hook that fetch data by id: const useGetData = (id: number) => { return useQuery({ queryKey: ["data-item", id], queryFn: () => getDataItemById(id), }); }; And I have hook that set item as liked: const useSetLike = ()…
1110
  • 7,829
  • 55
  • 176
  • 334
0
votes
1 answer

How to type response from useInfiniteQuery QueryFn?

I have a hook that use useInfiniteQuery: const useGetData = (page: number = 1) => { return useInfiniteQuery({ queryKey: ["data"], queryFn: () => getAllData(page), getPreviousPageParam: (firstPage) => firstPage.previousId ?? undefined, …
1110
  • 7,829
  • 55
  • 176
  • 334
0
votes
2 answers

how should I fetch my data with react-query in framework7-react?

Im working on an framework7-react and react query for data fetching. Initialization was fine, everything works perfectly, but when I want to fetch data with react-query it has this error "No QueryClient set, use QueryClientProvider to set one" and…
0
votes
0 answers

InvalidateQueries are executed at the wrong time

const { isLoading, error, data } = useQuery(["click"], () => makeRequest.get("/example/1234").then((res) => { return res.data; }) ); const Path = async (postId, cardNickNameId) => { const promise =…
0
votes
1 answer

Why is my react-query configuration fetching from cache?

I'm migrating a legacy codebase from saga (no cache) to react-query. My starting point is to replicate exactly as we have now, a very unoptimised approach, and optimise later, enabling cache piece by piece. I have the following immediate…
plusheen
  • 1,128
  • 1
  • 8
  • 23
0
votes
1 answer

Invalidate all queries but refetch only active

I want to achieve the behavior where after successful mutation, all queries with dependent data should be marked as invalid but only active should be refetched right away, and inactive should be refetched only whether they would become active. As I…
0
votes
1 answer

Nested/conditional chained API calls in React Query?

We need a function that may call an API or the other, and based on the result, call yet another API. Let me give a simplified example. We're trying to do something like this function getCarDetails(car: CarSummary): UseQueryResult { …
Aximili
  • 28,626
  • 56
  • 157
  • 216
0
votes
1 answer

React Tanstack useQuery showing 'pause' status on every query

All of mine queries showing the 'paused' status. Even though the 'enable' flag is true. Here is the screen of how devtools look like and the hook that calling the query import { useQuery } from "@tanstack/react-query"; const getWordInfo = async…
0
votes
0 answers

How to solve Text match Error such as SSR and CSR when using Suspense component in NextJS

stackoverflow 질문 I used Next13 and tanstack query. // page.tsx import { Suspense } from "react"; import { ErrorBoundary } from "react-error-boundary"; import { TimeStamp } from "./components/TimeStamp"; import { FallbackUi } from…
HM.Park
  • 757
  • 1
  • 5
  • 9
0
votes
0 answers

Error "Uncaught Error: could not find react-redux context value; please ensure the component is wrapped in a " thrown while it is wrapped

I receive subject error when try to add some functionalities of tan stack query to existing and working application. Here is the structure of basic files: index.tsx (main index file): ReactDOM.render( , …