React Query is now written in TypeScript to make sure the library and your projects are type-safe!
Install the latest version to get React Query with the new types:
npm install react-query --save
data
and error
properties.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()))}
The latest TanStack news, articles, and resources, sent to your inbox.