Skip to content
Source
Sign inSign up
TanStack/query

useInfiniteQuery didn't updates new data from api #8165

Send to my agent
Closedburhanyilmaz(GitHub profile, opens in a new tab) opened this issue 1 comment

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

  1. 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.

  2. TkDodo closed this

  3. TkDodo added labelsneeds-info

Sign in to join this conversation.