Skip to content

Commit

Permalink
docs(react-query): highlight per component select pattern for query o…
Browse files Browse the repository at this point in the history
…ptions (#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 <office@dorfmeister.cc>
  • Loading branch information
DogPawHat and TkDodo authored Jan 11, 2025
1 parent fd500a4 commit 8ddebc6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/framework/react/guides/query-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@ queryClient.setQueryData(groupOptions(42).queryKey, newGroups)
[//]: # 'Example1'

For Infinite Queries, a separate [`infiniteQueryOptions`](../reference/infiniteQueryOptions.md) helper is available.

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:

[//]: # 'Example2'

```ts
// Type inference still works, so query.data will be the return type of select instead of queryFn

const query = useQuery({
...groupOptions(1),
select: (data) => data.groupName,
})
```

[//]: # 'Example2'

0 comments on commit 8ddebc6

Please sign in to comment.