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

jolly-crimson
jolly-crimson3/9/2023

Solid Query: "mutate" is not a function when testing

Hello everyone. I have a page component Post.page.tsx that uses createQuery and createMutation. When I try to test that component, the error says TypeError: mutate is not a function. I have a test utils that's basically a wrapper of render from @solidjs/testing-library. The only place where I call mutate function in that page component is in onDeletePost function in Post.vm.tsx file which is used inside of Post.page.tsx, but only called when some button clicked. I'm not sure why the error says like so, even if I'm not even clicked anything in my test case....
No description
rival-black
rival-black3/8/2023

How to get new `useQuery` data inside a mutation's `onSuccess`?

```js const { data: projectWorkflows, } = useGetProjectWorkflowsQuery(project.id); ...
fascinating-indigo
fascinating-indigo3/8/2023

NextJS 13

I am pretty comfortable using React-Query these days but not so sure where it fits when working on a NextJS based site. Are there any resources that explain what benefits using react query with nextjs can provide?
xenial-black
xenial-black3/7/2023

useInfiniteQuery for pagination without page metadata or nextCursor

I have an API which takes in 2 parameters query 'q' and page 'p'. I have infinite scrolling for this API. Whenever page is increased I am appending the next page's response in a state variable with the previous one. And whenever q is changed I reset page 'p' to 1 and the state variable array is reset to new response. I was wondering I could use useInfiniteQuery hook for this but since my API does not give any metadata about next page I am not sure this could be even done. Can anyone share a simi...
robust-apricot
robust-apricot3/7/2023

Is it ok to call queryClient.fetchQuery() in a query fn?

I could use select, but let's say I want to reuse a cached value in multiple components in my UX. I think .select would need to run in each component my useQuery appears?
robust-apricot
robust-apricot3/7/2023

Does the result of the queryFn (data) need to be serializable?

Or could I return something like a class instance or function?
extra-lavender
extra-lavender3/7/2023

createWebStoragePersistor on React-Query v3

Hi everyone, I was wondering if i could get some help regarding using WebStorage Persitance in React query v3. The idea is we have multiple modules in using RQ, but i want to only persist in cache a subset of calls starting with the following key
/module/
/module/
. How could i do this ?...
other-emerald
other-emerald3/6/2023

Pausing Mutations when networkMode: "online"

Hello! I am working on a React Native app, attempting to persist paused mutations to async storage, using a default mutation fn and PersistQueryClientProvider. ReactQuery v4 My issue is my mutations immediately throw an error when my device is offline, even when my networkMode is set to "online". My assumption is because an error is thrown the mutation is never paused and never gets persisted. And when calling "queryClient.getMutationCache()", the mutations array is empty.
Any idea what could be going on?...
conventional-tan
conventional-tan3/6/2023

typeof useMutation

hello! I have a const mutator = useMutation({onSuccess,...}) i pass the mutator to child components .... what is the type of this object? Thank you!...
fair-rose
fair-rose3/6/2023

Update multiple keys after useQuery call

Hi, Is there any way to update the cache of multiple keys after a useQuery call. Tell me if I am thinking in the wrong way but it seems that this is necessary. ...
absent-sapphire
absent-sapphire3/5/2023

Are the errors in onSuccess callback are catch ?

Hello everyone, I have a pretty simple question but i can't find the answer. Imagine i have something like that: ```...
subsequent-cyan
subsequent-cyan3/5/2023

Shared Mutation Results

Hey! I found PR exposing mutation variables is very exciting! https://github.com/TanStack/query/pull/4814 Does it mean that we will be able to "pickup" to mutation state in situation as:...
deep-jade
deep-jade3/5/2023

How should one access queryclient in subcomponents?

Is there build in method to access the already created queryclient I have created and passed on root level to QueryClientProvider? if so, simple docs link is fine as I couldn't find method for that. I assume otherwise I just need to create my own react context? V4...
subsequent-cyan
subsequent-cyan3/4/2023

query-core docs

Hey! Perhaps some of you guys have a link to a blog post or even documentation on how to directly work with query-core? I want to build my own integration, reverse engineering such a time-consuming thing 😢...
like-gold
like-gold3/3/2023

My Mutation is stuck in loading state after successful request

Can't figure out what is going on here, made a POST request and it works fine. Im trying to do a GET Request now using a mutation with no luck. Just stuck in loading state. The data comes back fine and the request is successful, the state is just wrong ....
No description
eastern-cyan
eastern-cyan3/3/2023

Supabase - Tanstack Query issue

kinda lost right now. I think i understand a bit whats happening but a little confused. Not sure what to do. this is there error on page load. Error: invalid input syntax for type uuid: "undefined" at getUser (useUser.tsx:12:11) ```tsx...
ratty-blush
ratty-blush3/2/2023

Can i get feedback on this pagination code?

``` Notes: The code is working well, to my understanding, but i am not sure if thats how its suppose to be. If anyone can give me feedback if its written optimally, or it has flaws, please let me know. I also attached a picture of the query dev tools ...
No description
genetic-orange
genetic-orange3/2/2023

API Endpoints Question to take advantage of Query Keys

I currently only have a single GET request for the Users object below and curious if I should ask the API team to make new endpoints.
Current API Setup /users -> Have one GET for users which returns the object above. /users/{filters}. To get one user, which returns an array of users (I just do users[0] on response). filters = "?id=${id}"...
national-gold
national-gold3/2/2023

Showing 404 error, not unexpected end of JSON input

I have the following useQuery code in a react app and I'm testing my error handling. I entered an invalid URL so this will 404, and it does in the console. rq tries again a few times but ultimately the error thrown isn't a 404 error, it's "Unexpected end of json input" How can I get it to the show the http error, not the JSON parsing error? The http error is far more useful for users to report issues. ```js...
fascinating-indigo
fascinating-indigo3/1/2023

Fixing `useQuery` generic overload error

With ```ts /**...