-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-redux_v5.x.x.js
98 lines (79 loc) · 3.75 KB
/
react-redux_v5.x.x.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// flow-typed signature: a2c406bd25fca4586c361574e555202d
// flow-typed version: dcd1531faf/react-redux_v5.x.x/flow_>=v0.62.0
import type { Dispatch, Store } from "redux";
declare module "react-redux" {
import type { ComponentType, ElementConfig } from 'react';
declare export class Provider<S, A> extends React$Component<{
store: Store<S, A>,
children?: any
}> {}
declare export function createProvider(
storeKey?: string,
subKey?: string
): Provider<*, *>;
/*
S = State
A = Action
OP = OwnProps
SP = StateProps
DP = DispatchProps
MP = Merge props
MDP = Map dispatch to props object
RSP = Returned state props
RDP = Returned dispatch props
RMP = Returned merge props
Com = React Component
*/
declare type MapStateToProps<SP: Object, RSP: Object> = (state: Object, props: SP) => RSP;
declare type MapDispatchToProps<A, OP: Object, RDP: Object> = (dispatch: Dispatch<A>, ownProps: OP) => RDP;
declare type MergeProps<SP: Object, DP: Object, MP: Object, RMP: Object> = (
stateProps: SP,
dispatchProps: DP,
ownProps: MP
) => RMP;
declare type ConnectOptions<S: Object, OP: Object, RSP: Object, RMP: Object> = {|
pure?: boolean,
withRef?: boolean,
areStatesEqual?: (next: S, prev: S) => boolean,
areOwnPropsEqual?: (next: OP, prev: OP) => boolean,
areStatePropsEqual?: (next: RSP, prev: RSP) => boolean,
areMergedPropsEqual?: (next: RMP, prev: RMP) => boolean,
storeKey?: string
|};
declare type OmitDispatch<Component> = $Diff<Component, {dispatch: Dispatch<*>}>;
declare export function connect<Com: ComponentType<*>, DP: Object, RSP: Object>(
mapStateToProps: MapStateToProps<DP, RSP>,
mapDispatchToProps?: null
): (component: Com) => ComponentType<$Diff<OmitDispatch<ElementConfig<Com>>, RSP> & DP>;
declare export function connect<Com: ComponentType<*>>(
mapStateToProps?: null,
mapDispatchToProps?: null
): (component: Com) => ComponentType<OmitDispatch<ElementConfig<Com>>>;
declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object>(
mapStateToProps: MapStateToProps<SP, RSP>,
mapDispatchToProps: MapDispatchToProps<A, DP, RDP>
): (component: Com) => ComponentType<$Diff<$Diff<ElementConfig<Com>, RSP>, RDP> & SP & DP>;
declare export function connect<Com: ComponentType<*>, A, OP: Object, DP: Object,PR: Object>(
mapStateToProps?: null,
mapDispatchToProps: MapDispatchToProps<A, OP, DP>
): (Com) => ComponentType<$Diff<ElementConfig<Com>, DP> & OP>;
declare export function connect<Com: ComponentType<*>, MDP: Object>(
mapStateToProps?: null,
mapDispatchToProps: MDP
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, MDP>>;
declare export function connect<Com: ComponentType<*>, SP: Object, RSP: Object, MDP: Object>(
mapStateToProps: MapStateToProps<SP, RSP>,
mapDispatchToPRops: MDP
): (component: Com) => ComponentType<$Diff<$Diff<ElementConfig<Com>, RSP>, MDP> & SP>;
declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object, MP: Object, RMP: Object>(
mapStateToProps: MapStateToProps<SP, RSP>,
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
mergeProps: MergeProps<RSP, RDP, MP, RMP>
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
declare export function connect<Com: ComponentType<*>, A, DP: Object, SP: Object, RSP: Object, RDP: Object, MP: Object, RMP: Object>(
mapStateToProps: ?MapStateToProps<SP, RSP>,
mapDispatchToProps: ?MapDispatchToProps<A, DP, RDP>,
mergeProps: ?MergeProps<RSP, RDP, MP, RMP>,
options: ConnectOptions<*, SP & DP & MP, RSP, RMP>
): (component: Com) => ComponentType<$Diff<ElementConfig<Com>, RMP> & SP & DP & MP>;
}