@aappddeevv/dynamics-client-ui
Version:
## What is it? A library to help you create great dynamics applications.
32 lines (31 loc) • 1.28 kB
TypeScript
/// <reference types="react" />
/** HOC to cache a props value and pass a transformed value to the child.
* When the input value changes, transform it and pass it along. If no
* transform is specified, then pass it through directly. All other props
* are passed through. Transforms are asynchronous. Essentially, this allows
* you to cache some data as state passed through props but is expensive to obtain.
*/
import * as React from "react";
export interface Prop<I, O> {
/** Data that when changed should trigger a fetch. */
value?: I | null;
/** Transform the data. */
transform?: (value: I) => Promise<O>;
/** Data is added to the props of child using childProp name. */
propName?: string;
/** Provide a default value if value is empty. Typically () => ""|0|{}. */
emptyValue?: () => O;
/** Initial value. */
initialValue?: I;
}
export interface State<I, O> {
value?: I;
loading: boolean;
error?: Error;
}
export declare class FetchDataComponent<I, O> extends React.Component<Prop<I, O>, State<I, O>> {
constructor(props: any, context: any);
shouldComponentUpdate(nextProps: any, nextState: any): boolean;
componentWillReceiveProps(nextProps: any): void;
render(): React.ReactElement<any> | null;
}