UNPKG

1.57 kBTypeScriptView Raw
1import * as React from 'react';
2export interface WithFetchProps<TReturnedData> {
3 loading: boolean;
4 error?: any;
5 data?: TReturnedData;
6 invoke: (params: any) => void;
7}
8export interface IWrapperProps<TReturnedData> {
9 onSuccess?: (data: TReturnedData) => void;
10 onFail?: (error: any) => void;
11}
12export interface IState<TReturnedData> {
13 loading: boolean;
14 data?: TReturnedData;
15 error?: any;
16}
17export declare const withInvoke: <TReturnedData, TP extends object = {}>(integrationId: string, functionName: string) => (WrappedComponent: React.ComponentType<TP & WithFetchProps<TReturnedData>>) => {
18 new (props: TP): {
19 context: import("./bearer-provider").IBearerContextValue;
20 invoke: (params?: any) => Promise<void>;
21 render(): JSX.Element;
22 setState<K extends "error" | "loading" | "data">(state: IState<TReturnedData> | ((prevState: Readonly<IState<TReturnedData>>, props: Readonly<TP & IWrapperProps<TReturnedData>>) => IState<TReturnedData> | Pick<IState<TReturnedData>, K> | null) | Pick<IState<TReturnedData>, K> | null, callback?: (() => void) | undefined): void;
23 forceUpdate(callBack?: (() => void) | undefined): void;
24 readonly props: Readonly<{
25 children?: React.ReactNode;
26 }> & Readonly<TP & IWrapperProps<TReturnedData>>;
27 state: Readonly<IState<TReturnedData>>;
28 refs: {
29 [key: string]: React.ReactInstance;
30 };
31 };
32 displayName: string;
33 contextType: React.Context<import("./bearer-provider").IBearerContextValue>;
34};
35
\No newline at end of file