Skip to content

Commit

Permalink
docs(react-query): per component select pattern
Browse files Browse the repository at this point in the history
highlight per component select pattern for query options
  • Loading branch information
DogPawHat committed Jan 10, 2025
1 parent 564e549 commit bae2921
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 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,16 @@ 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:

```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 bae2921

Please sign in to comment.