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 initially false when there is no data for conditional queries. #2996

Open
fmacherey opened this issue Jul 19, 2024 · 0 comments

Comments

@fmacherey
Copy link

Bug report

I have a query (call them B, see below), which is initally not loading, and is loading and at the end is not loading again (as expected) when there is data, see screenshot with logging information:
image

I figured out, that it seems originating from the conditional query I use:

  1. is call query (A), while this the key of query (B) is null, to be disdabled.
  2. when query (A) has data, these are used as args for query (B), so key becomes defined now.
  3. With this pattern I observe the above mentioned bug, so I have to check isLoading and data, to be failsafe.

I am coming from tanstack/query, where you have more options like enable queries or have more then just one loading state, so maybe I am doing s.th. wrong? So please let me know.

Otherwise I would suggest to change isLoading state to take into account, that data !== undefined.

Additional Context

SWR version: 2.2.5
Next: 14.2.5
React: 18.2.0

@fmacherey fmacherey changed the title isLoading is initially false when there is no data. isLoading is initially false when there is no data for conditional queries. Jul 19, 2024
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

1 participant