Skip to content
Source
Sign inSign up
TanStack/query

Feature/query options #5153

MergedTkDodomerged 11 commits intoalpha fromrefs/pull/5153/headmerged by TkDodo View on GitHub

Showing 5 changed files with 44 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
4 additions and 0 deletionsdocs/react/guides/migrating-to-v5.mdModified
View file
@@ -439,6 +439,10 @@
​
Note that the infinite list must be bi-directional, which requires both `getNextPageParam` and `getPreviousPageParam` to be defined.
​
+### Typesafe way to create Query Options
+​
+See the [Typescript Docs](../typescript#typing-query-options) for more details.
+​
### CreateStore
​
We are now exposing a way to customize how queries are stored internally. Per default, a `Map` is used but, with the new `createStore` function, you can now use any data structure you want.
19 additions and 0 deletionsdocs/react/typescript.mdModified
View file
@@ -140,6 +140,25 @@
​
[//]: # 'Materials'
​
+## Typing Query Options
+​
+If you inline query options into `useQuery`, you'll get automatic type inference. However, you might want to extract the query options into a separate function to share them between `useQuery` and e.g. `prefetchQuery`. In that case, you'd lose type inference. To get it back, you can use `queryOptions` helper:
+​
+```ts