UNPKG

@drieam/common

Version:

Default Drieam api wrapper

82 lines (81 loc) 4.22 kB
import React from 'react'; import { EntityState, ListState } from '@drieam/api'; declare type ReduxState = ListState<any> | EntityState<any>; export declare type ApiWrapperProps = { fetch: () => void; state: ReduxState[] | ReduxState; modelName?: string; showNoneFoundMessage?: boolean; loader?: React.ReactNode; nextPage?: () => void; }; declare const withApiWrapper: <P extends object>() => (Component: React.ComponentType<P>) => { new (props: Readonly<ApiWrapperProps>): { readonly model: ReduxState[]; componentDidMount(): void; readonly isSingle: boolean; readonly settled: boolean; readonly rejected: boolean; readonly status: number | "Error"; readonly reason: string; renderSingle(): JSX.Element; render(): {}; context: any; setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<ApiWrapperProps>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void; forceUpdate(callBack?: () => void): void; readonly props: Readonly<ApiWrapperProps> & Readonly<{ children?: React.ReactNode; }>; state: Readonly<{}>; refs: { [key: string]: React.ReactInstance; }; shouldComponentUpdate?(nextProps: Readonly<ApiWrapperProps>, nextState: Readonly<{}>, nextContext: any): boolean; componentWillUnmount?(): void; componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<ApiWrapperProps>, prevState: Readonly<{}>): any; componentDidUpdate?(prevProps: Readonly<ApiWrapperProps>, prevState: Readonly<{}>, snapshot?: any): void; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<ApiWrapperProps>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<ApiWrapperProps>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<ApiWrapperProps>, nextState: Readonly<{}>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<ApiWrapperProps>, nextState: Readonly<{}>, nextContext: any): void; }; new (props: ApiWrapperProps, context?: any): { readonly model: ReduxState[]; componentDidMount(): void; readonly isSingle: boolean; readonly settled: boolean; readonly rejected: boolean; readonly status: number | "Error"; readonly reason: string; renderSingle(): JSX.Element; render(): {}; context: any; setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<ApiWrapperProps>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void; forceUpdate(callBack?: () => void): void; readonly props: Readonly<ApiWrapperProps> & Readonly<{ children?: React.ReactNode; }>; state: Readonly<{}>; refs: { [key: string]: React.ReactInstance; }; shouldComponentUpdate?(nextProps: Readonly<ApiWrapperProps>, nextState: Readonly<{}>, nextContext: any): boolean; componentWillUnmount?(): void; componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<ApiWrapperProps>, prevState: Readonly<{}>): any; componentDidUpdate?(prevProps: Readonly<ApiWrapperProps>, prevState: Readonly<{}>, snapshot?: any): void; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<ApiWrapperProps>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<ApiWrapperProps>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<ApiWrapperProps>, nextState: Readonly<{}>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<ApiWrapperProps>, nextState: Readonly<{}>, nextContext: any): void; }; defaultProps: Partial<ApiWrapperProps>; displayName: string; contextType?: React.Context<any>; }; export default withApiWrapper;