UNPKG

@bloc-js/react-bloc

Version:

React components for implementing the BLoC pattern.

35 lines (34 loc) 1.96 kB
import { Bloc } from "@bloc-js/bloc"; import { ComponentType } from "react"; export declare type BlocMap<M> = { [K in keyof M]: M[K] extends Bloc<any> ? M[K] : never; }; export declare function withBlocs<P extends {}, M>(creator: (props: P) => BlocMap<M>): (Comp: ComponentType<P & BlocMap<M>>) => { new (props: P): { blocs: BlocMap<M>; componentWillUnmount(): void; render(): import("react").ReactElement<P & BlocMap<M>, string | import("react").JSXElementConstructor<any>>; context: any; setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<P>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; forceUpdate(callback?: (() => void) | undefined): void; readonly props: Readonly<P> & Readonly<{ children?: import("react").ReactNode; }>; state: Readonly<{}>; refs: { [key: string]: import("react").ReactInstance; }; componentDidMount?(): void; shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): boolean; componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<{}>): any; componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<{}>, snapshot?: any): void; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): void; }; contextType?: import("react").Context<any> | undefined; };