Created
November 9, 2019 13:18
-
-
Save lukaszfiszer/0c1accfe49ede30f21ce99cfa6d51dcb to your computer and use it in GitHub Desktop.
Typings for react-query package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'react-query' { | |
export type QueryKey = string | Array<string, object>; | |
export type QueryKeyFunction = () => QueryKey; | |
export type QueryFunction<TReturn> = (...args: any[]) => Promise<TReturn>; | |
export type QueryOptions = { | |
manual: boolean | |
pagination: boolean | |
getCanFetchMore: (lastPage: number, allPages: number) => boolean | |
staleTime: number; | |
retry: boolean | number; | |
retryDelay: number; | |
suspense: number | |
refetchInterval: number | false | |
onError: (err) => void; | |
} | |
export type QueryResult<TReturn> = { | |
data: null | TReturn; | |
error: null | Error; | |
isFetching: boolean; | |
isCached: boolean; | |
failureCount: number | |
isLoading: boolean | |
refetch: Function | |
} | |
export function useQuery<TReturn>(queryKey: QueryKey | QueryKeyFunction, queryFn: QueryFunction<TReturn>, options?: Partial<QueryOptions>): QueryResult<TReturn>; | |
export type MutationFunction<TReturn> = (...args) => Promise<TReturn>; | |
export type MutationResult<TReturn> = { | |
data: TReturn; | |
isLoading: boolean; | |
error: null | Error | |
} | |
export function useMutation<TReturn>(mutationFn: MutationFunction<TReturn>): [MutationFunction<TReturn>, MutationResult<TReturn>]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lukaszfiszer thanks