Skip to content

Commit

Permalink
Merge branch 'alpha' into feature/no-modify-input
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo committed Apr 13, 2023
2 parents 67ebbdf + 5940415 commit 0335219
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/react/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ const { error } = useQuery({ queryKey: ['groups'], queryFn: fetchGroups })

[//]: # 'Playground5'

If you want to throw a custom error, or something that isn't an Error at all, you can specify the type of the error field:
If you want to throw a custom error, or something that isn't an `Error` at all, you can specify the type of the error field:

```tsx
const { error } = useQuery<Group[], string>(['groups'], fetchGroups)
// ^? const error: string | null
```

However, this has the drawback that type inference for all other generics of `useQuery` will not work anymore. It is generally not considered a good practice to throw something that isn't and `Error`, so if you have a subclass like `AxisError` you can use _type narrowing_ to make the error field more specific:
However, this has the drawback that type inference for all other generics of `useQuery` will not work anymore. It is generally not considered a good practice to throw something that isn't an `Error`, so if you have a subclass like `AxiosError` you can use _type narrowing_ to make the error field more specific:

```tsx
import axios from 'axios'
Expand Down

0 comments on commit 0335219

Please sign in to comment.