-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
37 lines (33 loc) · 1.07 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
declare module "react-axios-helpers" {
import React from "react";
import { AxiosInstance, AxiosRequestConfig, AxiosError } from "axios";
interface AxiosContextInterface {
instance: AxiosInstance;
}
interface TUseRequestOptions<TData, TProps> {
request: (
props: TProps,
data: TData
) => AxiosRequestConfig | undefined | null;
cancelOnUnmount?: boolean;
onRequest?: (props: TProps) => void;
onSuccess?: (data: TData, props: TProps) => void;
onError?: (error: AxiosError, props: TProps) => void;
onCancel?: (error: AxiosError, props: TProps) => void;
}
interface TUseRequestData<TData, TProps> {
data: TData;
error: AxiosError;
fetching: boolean;
fetched: boolean;
fetch: (props: TProps) => Promise<void>;
cancel: () => void;
canceled: boolean;
}
export const useRequest: <T, P = void>(
options: TUseRequestOptions<T, P>,
deps?: any[]
) => TUseRequestData<T, P>;
export const AxiosContext: React.Context<AxiosContextInterface>;
export const AxiosProvider: React.FC<AxiosContextInterface>;
}