Skip to content

Commit 8ddebc6

Browse files
DogPawHatTkDodo
andauthored
docs(react-query): highlight per component select pattern for query options (#8522)
* docs(react-query): per component select pattern highlight per component select pattern for query options * Update docs/framework/react/guides/query-options.md --------- Co-authored-by: Dominik Dorfmeister <[email protected]>
1 parent fd500a4 commit 8ddebc6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/framework/react/guides/query-options.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,18 @@ queryClient.setQueryData(groupOptions(42).queryKey, newGroups)
3232
[//]: # 'Example1'
3333

3434
For Infinite Queries, a separate [`infiniteQueryOptions`](../reference/infiniteQueryOptions.md) helper is available.
35+
36+
You can still override some options at the component level. A very common and useful pattern is to create per-component [`select`](../guides/render-optimizations.md#select) functions:
37+
38+
[//]: # 'Example2'
39+
40+
```ts
41+
// Type inference still works, so query.data will be the return type of select instead of queryFn
42+
43+
const query = useQuery({
44+
...groupOptions(1),
45+
select: (data) => data.groupName,
46+
})
47+
```
48+
49+
[//]: # 'Example2'

0 commit comments

Comments
 (0)