swr
swr copied to clipboard
isLoading is initially false when there is no data for conditional queries.
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:
I figured out, that it seems originating from the conditional query I use:
- is call query (A), while this the
keyof query (B) is null, to be disdabled. - when query (A) has data, these are used as args for query (B), so
keybecomes defined now. - 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
Can you please show me how to reproduce this in CodeSandbox?