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

metropolitan-bronze
metropolitan-bronze4/15/2024

How to implement infinite scroll in tanstack react query ?

I'd like to incorporate infinite scrolling into my project using React Query. As I scroll down the page, I want to send a request to the backend to fetch additional data. How can I implement this ?...
national-gold
national-gold4/15/2024

select performs correctly in local but in production i think it fails.

const [searchTerm, setSearchTerm] = useState(''); const { data: projectData } = useQuery({ queryKey: [${ProjectQueryKeys.fetchProjects}], queryFn: fetchProjects, select: (data) => {...
flat-fuchsia
flat-fuchsia4/14/2024

Is there a way to fetch notifications in real-time?

I've implemented a simple fetch query to retrieve notifications. However, I want to receive notifications instantly without needing to re-fetch, and it behaves somewhat like a subscription, Is there any method by react-query to react this behavior?
metropolitan-bronze
metropolitan-bronze4/14/2024

Type error in react query useMutation hook

Try to implement custom hook with useMuatation for POST request. Typescript is complaining that my createBook function Type '(bookData: Shop) => Promise' has no properties in common with type 'UseMutationOptions<Shop, Error, Shop, unknown>' . Here is an overview of my code. useCustoumMatation.ts import apiClient from "@/services/api/api-client"; ...
generous-apricot
generous-apricot4/13/2024

Wait invalidate infinite query

```const handleDeclineLeadOffer = async () => { if (!declineOfferReason) return showToast('Escolha uma opção de declínio'); if (shouldOnlyDeclineMeeting) { await meetingAction({...
tame-yellow
tame-yellow4/13/2024

How to remove dehydratedState from html?

I generate my pages with getStaticProps with NextJs. In <script id="NEXT_DATA" type="application/json">{"props":{"pageProps":{"dehydratedState"... i have my product_ids, which i dont want to be shown. How can i hide or encrypt this?...
No description
genetic-orange
genetic-orange4/11/2024

Handling rerendering and useMutation

Hi all, currently when wanting to force a rerender on a mutation I move the mutation up in state and pass it as a callback down to the component that needs to trigger it. This often results in prop drilling and coupled state. What is a better approach? Simplified example: ``` const Chat = () => {...
correct-apricot
correct-apricot4/11/2024

Purpose and necessity of QueryClient

Junior dev, newish to react-query & reading the docs - quick question. Among the first couple pages that I've read from the documentation (great documentation btw), there have been quick start examples of how to use it with some good explanations but I've come across the QueryClient on those occasions with little explanation. All I can remember from the API docs for the QueryClient is that it's used for caching. Yet the first couple examples have shown to use it along with the context provider but not much explanation or actual use of it. I'm sure I can get around to it but I'd really like to nail the fundamentals asap, so, can anyone clarify what the QueryClient is, its purpose and its necessity? Can you use useQuery without it?...
vicious-gold
vicious-gold4/10/2024

nextPage and prevPage params aren't updating.

```js import { useInfiniteQuery, keepPreviousData } from "@tanstack/react-query"; import { useState } from "react"; import fetchPage from "../utility/fetchPage"; ...
genetic-orange
genetic-orange4/8/2024

Call a useQuery hook only onClick and not when Component loads for the fist time

I would like to know your opinion about the solution I implemented in React. I need to call a hook that uses internally useQuery only when I click a button. What I did was to declare the hook on the component and set enable: false. With that, I avoid the first call. After that, I get the refetch property from the useQuery hook and I call it when the button clicks. I've seen that you can also use invalidateQuery, but I don't really know what would be the best option....
ambitious-aqua
ambitious-aqua4/7/2024

Is there any way to identify what are the parameters for the currently running mutation?

Is there any way to identify what the parameters for the currently running mutation are with useMutation? I am mapping over a list, where each item has a button that performs the same action with a different parameter. I am trying to show a loading indicator in the correct place. (I could move the list items to a child element and call the mutation from there but I'd rather not if possible)...
rare-sapphire
rare-sapphire4/6/2024

Type for global error in QueryCache & MutationCache

I have a little issue. I want to define my own types for global onError callback in queryCache & mutationCache. I need error to be type of AxiosError. I can't find a working solution. I'd be glad if someone helped me. Thanks! ```js const [queryClient] = useState( () =>...
eastern-cyan
eastern-cyan4/5/2024

Is there a way to rerun only partial code of a query?

Hey I have a question about queries. I have a query which makes multiple get requests and then does a Promise.all to resolve all promises. ```ts const useChangeTariff = (contractIds: string[]): UseQueryResult<ITariffChange[], void> => { return useQuery({...
stormy-gold
stormy-gold4/5/2024

Hello! I am trying to abort a POST request for example.

I have a modal that performs an API call, IF in the meantime I close the modal I want the API request to get canceled, anyone knows how to achieve that?
national-gold
national-gold4/5/2024

Native release or Codepush ?

Hey can anyone help me, we are adding react query for data fetching in our react native app, does it require a native release, As per my guess codepush should do the job as there is no native platform specific apis being used
plain-purple
plain-purple4/5/2024

mutation options

is there a way to use mutations like the queryOptions api? so something like: const addTodoMutation = mutationOptions({ mutationKey: ["todo", "add"], mutationFn: () => {}...
rare-sapphire
rare-sapphire4/4/2024

Controlled state mutation in useQuery

Hi! I am looking for some way to control when states are updated. So the use case is like based on some user action I am animating somwthing for 1-2s and based on the same callback I'm refetching the query or updating the params being passed to it. So, I want that both animation and data fetching happens in parallel and onAnimationEnd the data is updated into states exposed by react query. Kindly help
fair-rose
fair-rose4/4/2024

vue-query query return types are not unwraped in template?

Hello! New to vue-query so unsure if this is a user error but the return type of ```ts...
No description
conscious-sapphire
conscious-sapphire4/4/2024

Enable/Disable QueryDevtools on custom env?

Is there a way to use a custom environment variable (other than NODE_ENV) to based on a different variable? Basically I want to show it on a dev server, but not run the dev server in development mode.