@stated-library/react
Version:
React bindings for [`Stated Libraries`](https://github.com/bradfordlemley/stated-library)
40 lines (39 loc) • 3.07 kB
TypeScript
import * as React from 'react';
import { Observable } from '@stated-library/interface';
export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
export declare type GetProps<C> = C extends React.ComponentType<infer P> ? P : never;
export declare type Matching<InjectedProps, DecorationTargetProps> = {
[P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P];
};
declare function connect<InjectProps>(value$: Observable<InjectProps>): <C extends React.ComponentType<Matching<InjectProps, GetProps<C>>>>(WrappedComp: C) => {
new (props: any): {
link: any;
state: InjectProps;
componentDidMount(): void;
componentWillUnmount(): void;
render(): JSX.Element;
context: any;
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>) => {} | Pick<{}, K>) | Pick<{}, K>, callback?: () => void): void;
forceUpdate(callBack?: () => void): void;
readonly props: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>> & Readonly<{
children?: React.ReactNode;
}>;
refs: {
[key: string]: React.ReactInstance;
};
shouldComponentUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, nextState: Readonly<{}>, nextContext: any): boolean;
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
getSnapshotBeforeUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, prevState: Readonly<{}>): any;
componentDidUpdate?(prevProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, prevState: Readonly<{}>, snapshot?: any): void;
componentWillMount?(): void;
UNSAFE_componentWillMount?(): void;
componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, nextContext: any): void;
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, nextContext: any): void;
componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, nextState: Readonly<{}>, nextContext: any): void;
UNSAFE_componentWillUpdate?(nextProps: Readonly<JSX.LibraryManagedAttributes<C, Pick<GetProps<C>, Exclude<keyof GetProps<C>, keyof InjectProps>>>>, nextState: Readonly<{}>, nextContext: any): void;
};
displayName: string;
contextType?: React.Context<any>;
};
export default connect;
export { connect };