docs: make the incompatibility of skipToken
and refetch
more detailed
#7599
Labels
documentation
Improvements or additions to documentation
Describe the bug
First of all, thanks for
skipToken
Janeek and TkDodo 💜. This madeuseQuery()
a lot more enjoyable to use with TS, without a bunch of non-null assertions (which we would always inevitably get wrong by missing some).While in the process of migrating all our calls to it from
enabled
, had some tedious time spotting the root cause of thisMissing queryFn
error:query/packages/query-core/src/utils.ts
Lines 393 to 396 in bda8a54
Eventually figured it out, and it was a legacy
refetch()
call which was still present after the migration. While this was specified in docs, I believe there could be more details as far as what "doesn't work" means, either in terms of docs of error messaging:query/docs/framework/react/guides/disabling-queries.md
Line 15 in bda8a54
Not sure to which extent we would like to document the docs (i.e whether or not we would like to go into full details that
refetch()
will mount an observer and that there can't be an observer without an actualqueryFn()
), but as a developer usingskipToken
, I believe there would be good value in at least documenting the aforementioned behaviour, or even better, improve the checks and messaging of the error to reflect the cause.Your minimal, reproducible example
https://codesandbox.io/p/sandbox/great-snyder-t5vxyk?file=/src/App.js
Steps to reproduce
useQuery()
call withskipToken
refetch()
method for that queryMissing queryFn: <hash>
) untilqueryFn
actually becomes a function.Expected behavior
Either/or:
refetch()
will eventually result in aMissing queryFn
errorCannot call refetch() with skipToken
How often does this bug happen?
None
Screenshots or Videos
N/A
Platform
N/A
Tanstack Query adapter
react-query
TanStack Query version
5
TypeScript version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: