UNPKG

@commercetools-frontend/sdk

Version:
52 lines (51 loc) 2.25 kB
/// <reference types="commercetools__sdk-client" /> import { Component, JSX } from 'react'; import type { SuccessResult, HttpErrorType } from '@commercetools/sdk-client'; import type { TSdkAction } from '../../types'; type TSdkError = Error | HttpErrorType; type TActionCreatorArgs = unknown[]; type State = { isWaitingForCompletionOfFirstRequest: boolean; requestsInFlight: number; result?: SuccessResult['body']; error?: TSdkError; }; type TRenderOptions = { isLoading: boolean; refresh: () => Promise<void | SuccessResult['body']>; result?: State['result']; error?: State['error']; }; type DispatchProps = { dispatch: (action: TSdkAction) => Promise<SuccessResult['body']>; }; type OwnProps = { actionCreator: (...args: TActionCreatorArgs) => TSdkAction; actionCreatorArgs?: TActionCreatorArgs; shouldRefetch?: (prevArgs: TActionCreatorArgs, nextArgs: TActionCreatorArgs) => boolean; onSuccess?: (result: SuccessResult['body']) => void; onError?: (error: TSdkError) => void; render: (options: TRenderOptions) => JSX.Element; }; export type Props = DispatchProps & OwnProps; type StaticErrorHandler = (error: TSdkError) => void; export declare class SdkGet extends Component<Props, State> { static displayName: string; static errorHandler: StaticErrorHandler; state: { isWaitingForCompletionOfFirstRequest: boolean; requestsInFlight: number; result: undefined; error: undefined; }; isComponentMounted: boolean; changeRequestsInFlight: (delta: number) => void; componentDidMount(): void; componentDidUpdate(prevProps: Props): void; componentWillUnmount(): void; fetch: ({ dispatch, actionCreator, actionCreatorArgs, onSuccess, onError, }: Pick<Props, 'dispatch' | 'actionCreator' | 'actionCreatorArgs' | 'onSuccess' | 'onError'>) => Promise<void | import("@commercetools/sdk-client").Json>; refresh: () => Promise<void | import("@commercetools/sdk-client").Json>; render(): JSX.Element; } declare const _default: import("react-redux").ConnectedComponent<typeof SdkGet, import("react-redux").Omit<JSX.LibraryManagedAttributes<C, import("react-redux").GetProps<C>>, "dispatch"> & OwnProps>; export default _default;