react-ketting
Version: 
Ketting bindings for React
29 lines (28 loc) • 898 B
TypeScript
import { Resource, State } from 'ketting';
import * as React from 'react';
/**
 * The list of properties this HoC
 * will pass to the wrapped component
 */
declare type PassedProps<T> = {
    resource: Resource<T>;
    resourceState: State<T> | null;
    data: T | null;
};
/**
 * A Higher order component for listening to Ketting state.
 *
 * Wrapping your component using withResource will add the following props
 * to your component:
 *
 * * resourceState
 * * data
 *
 * 'resourceState' will refer to the result of a Ketting Resource.get() State
 * object, renamed to 'resourceState' to avoid confusion with react state.
 * ' data' is the 'body' of the result.
 */
export declare function withResource<TProps extends {
    resource: Resource<TResourceBody>;
}, TResourceBody>(WrappedComponent: React.ComponentType<TProps & PassedProps<TResourceBody>>): React.ComponentType<TProps>;
export {};