UNPKG

3.18 kBTypeScriptView Raw
1import * as React from "react";
2import { Observable } from "rxjs";
3import { Store } from "../src/store";
4import { ActionMap } from "./actions";
5export declare type ExtractProps<TComponentOrTProps> = TComponentOrTProps extends React.ComponentType<infer TProps> ? TProps : TComponentOrTProps;
6export interface ConnectResult<TAppState, TOriginalProps> {
7 props?: Observable<TOriginalProps>;
8 actionMap?: ActionMap<TOriginalProps>;
9}
10export declare type ConnectCallback<S, P, TInputProps> = (store: Store<S>, inputProps: Observable<TInputProps>) => ConnectResult<S, P>;
11export interface ConnectState<TOriginalProps> {
12 connectedProps?: Partial<TOriginalProps>;
13 ready: boolean;
14}
15/**
16 * Connects a Component's props to a set of props of the application state coming from a Store object.
17 */
18export declare function connect<TAppState, TOriginalProps extends {}, TInputProps extends {} = {}>(ComponentToConnect: React.ComponentType<TOriginalProps>, connectCallback: ConnectCallback<TAppState, Partial<TOriginalProps>, TInputProps>): {
19 new (props: any): {
20 render(): JSX.Element;
21 context: any;
22 setState<K extends "connectedProps" | "ready">(state: ConnectState<TOriginalProps> | ((prevState: Readonly<ConnectState<TOriginalProps>>, props: Readonly<TInputProps & Partial<TOriginalProps>>) => ConnectState<TOriginalProps> | Pick<ConnectState<TOriginalProps>, K> | null) | Pick<ConnectState<TOriginalProps>, K> | null, callback?: (() => void) | undefined): void;
23 forceUpdate(callback?: (() => void) | undefined): void;
24 readonly props: Readonly<TInputProps & Partial<TOriginalProps>> & Readonly<{
25 children?: React.ReactNode;
26 }>;
27 state: Readonly<ConnectState<TOriginalProps>>;
28 refs: {
29 [key: string]: React.ReactInstance;
30 };
31 componentDidMount?(): void;
32 shouldComponentUpdate?(nextProps: Readonly<TInputProps & Partial<TOriginalProps>>, nextState: Readonly<ConnectState<TOriginalProps>>, nextContext: any): boolean;
33 componentWillUnmount?(): void;
34 componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
35 getSnapshotBeforeUpdate?(prevProps: Readonly<TInputProps & Partial<TOriginalProps>>, prevState: Readonly<ConnectState<TOriginalProps>>): any;
36 componentDidUpdate?(prevProps: Readonly<TInputProps & Partial<TOriginalProps>>, prevState: Readonly<ConnectState<TOriginalProps>>, snapshot?: any): void;
37 componentWillMount?(): void;
38 UNSAFE_componentWillMount?(): void;
39 componentWillReceiveProps?(nextProps: Readonly<TInputProps & Partial<TOriginalProps>>, nextContext: any): void;
40 UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TInputProps & Partial<TOriginalProps>>, nextContext: any): void;
41 componentWillUpdate?(nextProps: Readonly<TInputProps & Partial<TOriginalProps>>, nextState: Readonly<ConnectState<TOriginalProps>>, nextContext: any): void;
42 UNSAFE_componentWillUpdate?(nextProps: Readonly<TInputProps & Partial<TOriginalProps>>, nextState: Readonly<ConnectState<TOriginalProps>>, nextContext: any): void;
43 };
44 contextType?: React.Context<any> | undefined;
45};
46
\No newline at end of file