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

unwilling-turquoise
unwilling-turquoise10/19/2022

broadcastQueryClient

I saw it is still in beta is it going to stable soon? And also at which version of tanstack is broadcastQueryClient supported? Thanks for the help...
foreign-sapphire
foreign-sapphire10/19/2022

Filtering through returned data

Where should I be filtering through the data, what's best practice? Would it be onSuccess? At the moment I am doing it like this: ``` export const fetchEmployers = () => { const platformEmployerTypes = [1, 3];...
metropolitan-bronze
metropolitan-bronze10/18/2022

Debounce a mutation, but not optimistic update?

Hello! Working on a document editor where the contents of the document affects other parts of the app. Trying to get it so that as people type the immediate optimistic update runs and the rest of the app can adjust, but not actually post the mutation on every keystroke. What's the best way to do this?
fascinating-indigo
fascinating-indigo10/18/2022

How to give a placeholder value for the result of the select function and have data always defined?

Given the following useQuery ```js const customHook = () => useQuery(['key'], queryFN, {select: (data) => ({x: data.x, y: data.y})} )...
protestant-coral
protestant-coral10/18/2022

Syncing react query data with useState state

Hi all, I have a provider which is fetching a list of "KeyRecord" from the backend. This provider provides the state of a list of forms, each form allows to edit a single KeyRecord. When the provider is done fetching the list of KeyRecord from the backend, it needs to initialize the state of the forms. The problem is, because I do that with a useEffect, there is a small timeframe where isLoading is false, and keyRecordsFormState is an empty array [] and I would like to get rid of that because it causes an unnecessary render of the consumers with an empty list. ...
foreign-sapphire
foreign-sapphire10/17/2022

A bit of help using a spreader function to update a toggle with optimistic updating

Trying to use a spreader function to use optimistic toggling. I would explain with super detailed code but its a bit late and I've been trying to sort this for quite awhile. Ok. Everything in my code works perfectly, API calls, optimistic updating looks and functions great. I'm not trying to add something (as in a to do list or a list of names/users) I am trying to toggle an existing list. If I don't use the spreader, when I click a button all I get is that button, if I do, every time I click it appends the array adding another toggle, mind you with the correct state. Please. Please help. I just want to have my existing list of buttons update optimistically and spread in the old products without creating a new button every time I click one....
foreign-sapphire
foreign-sapphire10/16/2022

A bit of help with useMutation

New to React Query -- just started today. It's been an absolute breeze. Wonderful work to anyone who has worked on it. I'll send code if necessary, but it's more of a theoretical question. I'm using "useMutation" to send a put request to my server. It updates on the server, but the actual state on my app doesn't change, the data on the site doesn't refresh, unless I click away and click back, or if I actually refresh the page. If this not part of useMutation? Do I need to implement something specific to get this functionality? (similar to adding a dep array in useEffect). I did attempt to use onSuccess to run queryClient.setQueryData to get what I needed to no avail....
correct-apricot
correct-apricot10/14/2022

useQuery helper functions to access returned data?

So we have an API request that fetches two large maps. We have many helper functions like this across the app, keeping the large maps in one scope but importing these util functions around. We are in the process of making this API fetch to useQuery and stuck wondering whats the best way to return helper functions that access that data? ``` getTokenByMint: (mint: string): MinimalTokenInfo | undefined => { return tokenMap[mint]; },...
stormy-gold
stormy-gold10/14/2022

Best practice

Hey there! I was wondering if there was a better way of doing this: ```jsx export function useCancelSubscription() { const queryClient = useQueryClient();...
national-gold
national-gold10/14/2022

useQueries Cancellation

Is there a way to pass an AbortSignal to a query function when using useQueries?
foreign-sapphire
foreign-sapphire10/14/2022

Setting error from the server in useMutation

I am using the useMutation hook to post data to the backend. I need to render the error message received from the backend. I can't seem to destructure the error message correctly. How do I set the error message to the onError prop? ```...
stormy-gold
stormy-gold10/14/2022

Refetches after disabling

Hey there! I have a query which activates when a modal opens. It uses the open variable to determine whether or not the query is enabled. Whenever I close and reopen the modal it refetches. Is there a way to precent this behaviour?
foreign-sapphire
foreign-sapphire10/14/2022

React Query Streaming JSON

I've got an API I created that sends out NDJson. I've hooked it up to a parser on my frontend to parse it into objects. However, I wanted to see if theres a way I can use react query to handle this data and cache it?
magic-amber
magic-amber10/13/2022

why queryCache state status is loading?

Hi i am a student learning react query now first my english writing is bad.. here is my question ...
No description
deep-jade
deep-jade10/13/2022

How to type custom cell?

How to type this case correctly?
No description
like-gold
like-gold10/13/2022

react-query triggers a re-reneder every X seconds on react native.

My query looks something like this ``` useQuery(['someKey'], somePromise, { notifyOnChangeProps: ['data', 'isLoading'], })...
optimistic-gold
optimistic-gold10/12/2022

Using Zustand, React Query, and Jotai

Hey folks, I'm trying to understand when I should use each of the above technologies. From what I understand, React Query is a server-state library for keeping your client updated with the state coming from the server. Zustand is a client state library used to store data coming from the server...? Jotai is good for storing one off "atoms" (which I'm assuming are basically stuff that you'd usually store in localStorage, etc?). Are those accurate use cases for each?
foreign-sapphire
foreign-sapphire10/12/2022

Unsuccessful attempt to migrate react-query v3 to v4

Hi! I'm trying to migrate v3->v4, doing what the docs say but get "Error: No QueryClient set, use QueryClientProvider to set one"
foreign-sapphire
foreign-sapphire10/12/2022

How to manage 'data is undefined'

I am working on a migration from redux to RQ. Our existing codebase is full of useEffect's which RQ is slowly replacing which is great, however, there are some instances where the app is breaking as the data is rendering as undefined but useEffect is expecting the value ( I agree we are using useEffect incorrectly probably but maybe there is a fix?). An example is that we logout a user if they are not authenticated on a particular journey. However, a user may indeed be authenticated but the value is undefined so considered falsy. ```...
like-gold
like-gold10/12/2022

Updating multiple query keys from an API with a batched endpoint

Hey, I'm querying an API with an endpoint someting like: api/prices/asset1,asset2,asset3 You can request the prices of as many assets as you wish. Is there a way I can use useQuery (or similar) to request this data, but then cache against a set of query keys rather than a single one?...