Skip to content

Tag: react-query

What are staleTime and cacheTime in React-Query?

I have read React Query docs. Still, I do not understand how to use staleTime & cacheTime for data caching. I want to store data for 2 mins in the cache after first-time API call. No matter if the component mounts or unmounts, I don’t want an API call for 2 mins after the first time I got the data.

Using QueryClientProvider in a Wrapper

I want to use a single Wrapper Component in a library im providing. The wrapper should provide stuff like Context and QueryClient. The component looks like this: When wrapping children with the Wrapper useQuery throws an error that no QueryClientProvider is set. In this case App uses the useQuery Hook from re…

React Query with hooks is throwing error, “Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.”

I am working on a React JS project that is using React query, https://react-query.tanstack.com/, React hooks and functional components. But it is throwing error when I use react query for API call. This is my component and how I use query within it. This is my getList API call logic When I run my code, I get …