Infinite Queries states are conflict #3744
Replies: 2 comments 4 replies
-
not sure what the "issue" here is. isFetching is always true when a request is going out. isRefetching is true if you are fetching and have fetched before. isFetchingNextPage is true if you are fetching the next page. Naturally, some of those flags can overlap.... |
Beta Was this translation helpful? Give feedback.
-
I was a bit confused by this too, specifically by the fact that I have a component that displays a list of posts, that is hooked up with useInfiniteQuery. When a new page is being fetched ( But, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Im using useInfiniteQuery and noticed the states of isLoading, isFetching, isRefetching, isFetchingNextPage are changing at the same time when calling fetchNextPage or refetch. As follows:
when calling refetch isFetching and isRefetching the same change:
{isFetching: true isFetchingNextPage: false isLoading: false isRefetching: true}
When calling fetchNextPage isFetching, isFetchingNextPage, isRefetching the same changes:
{isFetching: true isFetchingNextPage: true isLoading: false isRefetching: true}
My code:
const { data, isLoading, isFetching, remove, refetch, isRefetching, isFetchingNextPage, fetchNextPage, hasNextPage, isError, } = useInfiniteQuery( ['products', id, params], ({pageParam}) => fetchListProduct(id, params, pageParam), { refetchOnMount: 'always', getNextPageParam: (lastPage, allPages) => lastPage?.products.length >= 20 ? allPages.length + 1 : undefined, behavior: { onFetch: async () => { await queryClient.cancelQueries(['products', partial, params]); }, }, } );
Your minimal, reproducible example
Steps to reproduce
calling fetchNextPage or refetch
Expected behavior
separate the state according to each specific actions
How often does this bug happen?
No response
Screenshots or Videos
No response
Platform
macOS
react-query version
~4.0.0-beta.23
TypeScript version
No response
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions