Skip to content

2.0.8

Compare
Choose a tag to compare
@liaoliao666 liaoliao666 released this 18 Oct 02:56
· 46 commits to main since this release

Changes

feat: automatically infer TQueryData by TQueryKey
feat: include TError in the return type of getOptions
feat: using useSuspenseQuery instead of useQuery in v5

Benefit from ReactQuery v5

Automatically infer TQueryData from TQueryKey

const useTest = createQuery({
  primaryKey: 'test',
  queryFn: () => `string`,
})

const data = queryClient.getQueryData(useTest.getKey())
//     ^? const data: string | undefined

Register a global error

declare module '@tanstack/react-query' {
  interface Register {
    defaultError: AxiosError
  }
}

const useTest = createQuery({
  primaryKey: 'test',
  queryFn: () => `string`,
})

const { error } = useTest()
//      ^? const error: AxiosError | null