You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type '{ queryKey: string[]; }' is not assignable to parameter of type 'QueryKey'.
Object literal may only specify known properties, and 'queryKey' does not exist in type 'readonly unknown[]'.ts(2345)
I did check the typescript signature of find, findAll and I found out that in fact it does not match the documentation :
To resolve this typescript error I had to use this instead : const query = queryCache.find(['posts'])
Also, it was not explicit that we had to add the QueryCache instance to the QueryClient in order to work properly. Check out the example in the sandbox.
Uncomment where it's written to and comment the good way to do
Enjoy the typescript error !
Expected behavior
Edit the documentation to match the actual typescript signature (or the contrary)
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Not related
Tanstack Query adapter
react-query
TanStack Query version
v4.27.0
TypeScript version
v4.4.2
Additional context
No response
The text was updated successfully, but these errors were encountered:
AaronActu
changed the title
QueryCache's documentation about find functions does not match use
QueryCache's documentation of the find functions does not match its usage
Mar 22, 2023
sorry for that. We've adapted the docs to how it will work in v5, where we will only pass filters to each function. Most function have overloads, like:
Describe the bug
Hey there,
I was trying to use the
QueryCache
provider like it was described in the documentation.I directly faced a typescript error :
I did check the typescript signature of find, findAll and I found out that in fact it does not match the documentation :
To resolve this typescript error I had to use this instead :
const query = queryCache.find(['posts'])
Also, it was not explicit that we had to add the
QueryCache
instance to theQueryClient
in order to work properly. Check out the example in the sandbox.Your minimal, reproducible example
https://codesandbox.io/s/react-query-cache-doc-error-gsjqw3?file=/src/App.tsx
Steps to reproduce
Expected behavior
Edit the documentation to match the actual typescript signature (or the contrary)
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Not related
Tanstack Query adapter
react-query
TanStack Query version
v4.27.0
TypeScript version
v4.4.2
Additional context
No response
The text was updated successfully, but these errors were encountered: