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

deep-jade
deep-jade1/3/2023

Programmatically set error on query with query client

Hey gang. I know it's possible to set query data using queryClient.setQueryData. Is it possible to set the error for a query? I can't seem to find the appropriate API to do that. As context: I've created a live query framework on top of React Query that fetches initial data while subscribing to updates via websockets. When websocket updates come in, the query cache is updated with queryClient.setQueryData. However, it's possible for websocket updates to return errors after the initial data is returned. I would love to be able to rely on React Query for handling these errors, but I don't know of a way to tell React Query that there is an error aside from throwing an error in the query function, which would be complicated to do in this circumstance....
foreign-sapphire
foreign-sapphire1/3/2023

Using next Router with useQuery

Hello, I want to use useQuery by sending a param that I get from the next12 router. thing is, the router is async, so the "cid" i'm sending in here is undefined. How can I handle this? ...
sensitive-blue
sensitive-blue1/3/2023

React query devtools is empty despite having a successfully query

I seem to being having a strange issue where my dev tools for react query is reporting 0 queries despite having a working query. I'm not having any errors in my console and it also handles errors too. Just nothing will show up in the dev tools for some reason. In the attached screenshot the questions in the FAQ are loaded from our DB using react query....
No description
xenial-black
xenial-black1/2/2023

useQuery with onSubmit

How would I use useQuery in a search page? I have a page with some search fields & when user submits this form a search is made. And I would like to useQuery to work with this because it is also possible to change the items found. Currently if I change the items these changes are not shown unless I re-run the search.
stormy-gold
stormy-gold1/2/2023

React Query with SSR(NextJS V12) Api Calling Issue.

Currently I am using getInitialProps to fetch my data. And after fetching I am dehydrating the data, it is working fine as expected. But the issue is when I am doing Client side navigation, my Api calling is happening (from useQuery). But if I enable shallow routing then the API calling is not happening. Now how can I disable API calling without using shallow ? PS: I've already tried some solution from https://github.com/vercel/next.js/discussions/19611.
` if (typeof window !== 'undefined') {...
quickest-silver
quickest-silver1/2/2023

Refetch is not happening (dependent query)

Hello ! I setup a dependent query in way to refetch as my value change. I would like to update my "applications" when my "environnementId" change, not only on the first render....
No description
liable-blush
liable-blush12/31/2022

How to handle error from useMutation

Hi, i have this function that updates the post ```export const updatePost = async (payload: MutationPayload) => { let { error, data } = await supabase .from("posts") .update(payload.body)...
fair-rose
fair-rose12/30/2022

Why am I getting unhandled errors using useQuery?

Hello, I am confused as to why I am getting unhandled error using useQuery, I thought it handles it itself? Am I using it wrong? ```...
No description
fascinating-indigo
fascinating-indigo12/30/2022

useQuery with POST and body

I have this mutation whose response I need, and there is no corresponding query for this mutation. However, only reason why I set this up as a mutation is cause it is POST request and needs body. It seems to me I would benefit if this could be query not mutation, but if query can make POST request and I can provide body to it, as I need this response cached....
liable-blush
liable-blush12/30/2022

How can i assure to typescript the argument type of useMutation ?

I have this function that mutate posts ```export const useMutatePost = (type: "create" | "update" | "delete") => { const queryClient = useQueryClient(); switch (type) {...
absent-sapphire
absent-sapphire12/30/2022

Why is refetch not being called?

I have a case when a query is made and then in a useEffect I get the user's location and use refetch to make the request again. Depending on the user's device, getting the location may be very fast, less than 1 second, and then react query is dropping is dropping the refetch. I guess it is dropping it because not enough time passed from the first request? How can I tell react-query: trust me. I know what I am doing and make the request regardless how much time passed. I also want stale time to be infinity. ...
ratty-blush
ratty-blush12/29/2022

How to reflect mutation post in the actual (fetch) data?

Hi, I started today using react-query, and I am pretty impressed with the results I've achieved so far. However I am with a problem: I have the following useQuery: ```jsx const {data: categories, isLoading: isCategoriesLoading, setData: setCategoriesData} = useQuery(...
deep-jade
deep-jade12/29/2022

How can I use MutationCache to get the mutation result on different route?

I have a scenario where I use mutation to post a data and then get back the reponse. Now I have to redirect to different page and display the result from the previous mutation. Can I use the mutationCache to get the result and display on the page?
like-gold
like-gold12/28/2022

React-query-devtools for react-native

I saw this, where do I start ?
No description
correct-apricot
correct-apricot12/28/2022

quearyKey type issue

I was expecting QueryKey, but you passed { queryKey: string[]; queryFn: (searchString: string) => Promise<any>; }
No description
sensitive-blue
sensitive-blue12/27/2022

Managing case when query is dependent on nextjs router.query but should update conditionally

What I want to achieve is that my query keys are dependent on router.query and not change if react.query.isTab is the same. It is a true false value, Currently whenever I click on any Tab in as shown in SS1 the nav bar is lost because mesages from that channels are fetched, I need to maintain some sort of state say react.query.isTab so that the nav bar data doesnt update if users is switching between the tabs. It should only update if users search for a new query,
No description
fair-rose
fair-rose12/24/2022

Getting undefined from fetched data on 1st onChange event from an input, don't know why.

My Hook ```js const useFetchAllUsers = () => { const { data: allUsersData,...
other-emerald
other-emerald12/23/2022

Understanding SSR & persisting query cache

We currently have an SPA using React Query with a local query cache. Some of the queries to populate the cache can be a bit slow, so having a local storage query cache persistence is a livesaver - it means the app loads straight away with slightly stale data, while that data is being refreshed in the background. I am considering implementing SSR to get some of the benefits of that but I'm a bit confused about how it fits together....
like-gold
like-gold12/23/2022

query Auth check combined with Mocks

I check with useQuery that user is Authored on server but, i also have functionality to turn on Mocks, which means user is always Auth (no need to check on server) So now i call Auth Query on app mount and store result in a Context. In the same page i am able to set Context Auth value to true if mock_mode is on....
fair-rose
fair-rose12/23/2022

How do I prefetch the pageProps.json dehydration request?

Background: I'm using react-query in Next.js with hydration. Every time I request a new page, there will be a request before the navigation. The request path is like .../pageName.json?query=xxx which returns the props in getServerSideProps. Question: But the request takes some time to finish, and makes the navigation not smooth. Is there any way to prefetch the pageProps request so that the navigation can be more smooth? Thank you in advance....