Skip to content

Commit 9608f80

Browse files
authored
docs(react-query): recommend against throwing errors in select (#8041)
Explaining why you should not thow errors in the select function Closes #8039
1 parent acb5d37 commit 9608f80

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/framework/react/guides/render-optimizations.md

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export const useTodoCount = () => {
4343

4444
A component using the `useTodoCount` custom hook will only re-render if the length of the todos changes. It will **not** re-render if e.g. the name of a todo changed.
4545

46+
> Note: `select` operates on successfully cached data and is not the appropriate place to throw errors. The source of truth for errors is the `queryFn`, and a `select` function that returns an error results in `data` being `undefined` and `isSuccess` being `true`. We recommend handling errors in the `queryFn` if you wish to have a query fail on incorrect data, or outside of the query hook if you have a error case not related to caching.
47+
4648
### memoization
4749

4850
The `select` function will only re-run if:

0 commit comments

Comments
 (0)