Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/src/pages/docs/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ npm install react-query --save

- The query results are no longer discriminated unions, which means you have to check the actual `data` and `error` properties.
- Requires TypeScript v3.8 or greater

## Defining Custom Hooks

When defining a custom hook you need to specify the result and error types, for example:

export function useGroups() {
return useQuery<Group[], Error>(
'list-groups',
() => fetch(`/api/groups`).then(res => res.json())
)
}