Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isLoading is false on refetch after error in v2.2.5 #4479

Closed
rusnick31 opened this issue Jun 24, 2024 · 1 comment
Closed

isLoading is false on refetch after error in v2.2.5 #4479

rusnick31 opened this issue Jun 24, 2024 · 1 comment

Comments

@rusnick31
Copy link

http.get('*', async () => {
    return HttpResponse.json(null, { status: 500 });
}),
const Component: FC = () => {
  const { isLoading, data, isError, refetch } = useGetDataQuery();
  console.log({ isLoading, isError });

  if (isLoading) {
    return <div>Loading...</div>;
  }

  if (isError) {
    return <button onClick={refetch}>refetch</button>;
  }

  ...

}

in v2.2.3 such component would render
{ isLoading: true, isError: false }
{ isLoading: false, isError: true }
then when I click refetch
{ isLoading: true, isError: false }
{ isLoading: false, isError: true }

but now with v2.2.5
{ isLoading: true, isError: false }
{ isLoading: false, isError: true }
after refetch
{ isLoading: false, isError: false }
{ isLoading: false, isError: true }

so in v2.2.5 isLoading is false after refetch even though there's no data

is it a bug? or from v2.2.5 we should use isFetching all the time?

@EskiMojo14
Copy link
Collaborator

EskiMojo14 commented Jun 24, 2024

from the docs:

isLoading - When true, indicates that the query is currently loading for the first time, and has no data yet. This will be true for the first request fired off, but not for subsequent requests.
isFetching - When true, indicates that the query is currently fetching, but might have data from an earlier request. This will be true for both the first request fired off, as well as subsequent requests.

Refetches shouldn't have ever affected isLoading, so this sounds like a bug has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants