TanStack / query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
https://tanstack.com/query
MIT License
42.75k stars 2.92k forks source link

useInfiniteQuery didn't updates new data from api #8165

Closed burhanyilmaz closed 1 month ago

burhanyilmaz commented 1 month ago

Describe the bug

I have a group list screen that fetches groups when opened. After changing a group name on the backend and navigating back to the previous screen, I return to the group list screen, but the group name is not updated. When I check the Axios response, the API returns the updated group name correctly, but Tanstack Query does not update.

// 
  useInfiniteQuery({
    queryKey: ['key', { pageSize, search }],
    queryFn: ({ pageParam }) =>
      getPaginatedGroup({ page: pageParam as number, pageSize, search }),
      getNextPageParam: (lastPage, allPages) =>
    allPages.length >= lastPage.pagination.totalPages ? undefined : allPages.length + 1,
  initialPageParam: 1,
  placeholderData: keepPreviousData,
  });

Your minimal, reproducible example

https://github.com/TanStack

Steps to reproduce

I have a group list screen that fetches groups when opened. After changing a group name on the backend and navigating back to the previous screen, I return to the group list screen, but the group name is not updated. When I check the Axios response, the API returns the updated group name correctly, but Tanstack Query does not update.

Expected behavior

I have a group list screen that fetches groups when opened. After changing a group name on the backend and navigating back to the previous screen, I return to the group list screen, the group name should be updated.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

macOS

Tanstack Query adapter

None

TanStack Query version

^5.56.2

TypeScript version

~5.3.3

Additional context

No response

TkDodo commented 1 month ago

Thank you for filing this issue, but we need more information before looking into this.

Specifically, a minimal, standalone, runnable reproduction is needed - preferably with codesandbox or stackblitz. If your issue is TypeScript related, prefer a TypeScript playground.

We'll close this issue for now, but we'll certainly re-open it if there is a proper reproduction.