Replies: 1 comment 7 replies
-
it's not allowed to return There should also be an error in the console in dev mode: query/packages/query-core/src/query.ts Lines 475 to 477 in 35539bf |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there 👋
When using a query that return
undefined
, the cacheTime and refetch options are not taken into account. It could happen that a call to a server return an undefined value, and we don't want to re-request to prevent too much server-side computations.We can also want to use useQuery as a better useEffect, that should return nothing.
The workaround is to return something, but it's not really explicit for developer, and is not good for maintainability as not every developer knows about that tricky solution 😭
If it's to know if a cache exists for that query, react-query should use:
For:
instead of
That's a DX issue, so what do you think about that ?
Thanks 🙌
Beta Was this translation helpful? Give feedback.
All reactions