triviality-react
Version:
Exposes triviality service container to react components
23 lines (22 loc) • 842 B
TypeScript
import * as React from 'react';
import { Context, ReactNode } from 'react';
export declare type ServiceContainerContextValue<T> = {
serviceContainer: T;
} | null;
export declare const ServiceContainerContext: Context<ServiceContainerContextValue<any>>;
export interface ServiceContainerProviderProps<T> {
children: ReactNode;
factory: Promise<T>;
}
export interface ServiceContainerProviderState<T> {
serviceContainer?: T;
error: string | null;
}
/**
* This ServiceContainerProvider can be nested with each other, passes to level container to all children.
*/
export declare class ServiceContainerProvider<T> extends React.PureComponent<ServiceContainerProviderProps<T>, ServiceContainerProviderState<T>> {
state: ServiceContainerProviderState<T>;
render(): React.ReactNode;
private handleConsumeCallback;
}