Skip to content

isLoading resolves data as undefined #9096

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

Closed
liel-almog opened this issue May 2, 2025 · 1 comment
Closed

isLoading resolves data as undefined #9096

liel-almog opened this issue May 2, 2025 · 1 comment

Comments

@liel-almog
Copy link

Describe the bug

If fetching a query and then checking for isError and isLoading and return if either, the data keyword can still be undefined while isLoading is the same as isFetching && isPending according to the docs.
So if you add an and operation it still needs to be defined.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/msy6g5?file=%2Fsrc%2FApp.tsx%3A23%2C30

Steps to reproduce

Hover the type inference.

Expected behavior

The type should not have undefined

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Linux

Tanstack Query adapter

react-query

TanStack Query version

5.69.0

TypeScript version

5.7.2

Additional context

No response

@TkDodo
Copy link
Collaborator

TkDodo commented May 2, 2025

that’s on purpose. if you want type narrowing, you need to check for isPending

@TkDodo TkDodo closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants