forked from cruise-automation/webviz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
react-router_v4.x.x.js
141 lines (122 loc) · 3.48 KB
/
react-router_v4.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// flow-typed signature: 392b7ed1ca3c83fef4daf36fce467f6c
// flow-typed version: c6154227d1/react-router_v4.x.x/flow_>=v0.104.x
declare module "react-router" {
// NOTE: many of these are re-exported by react-router-dom and
// react-router-native, so when making changes, please be sure to update those
// as well.
declare export type Location = {
pathname: string,
search: string,
hash: string,
state?: any,
key?: string,
...
};
declare export type LocationShape = {
pathname?: string,
search?: string,
hash?: string,
state?: any,
...
};
declare export type HistoryAction = "PUSH" | "REPLACE" | "POP";
declare export type RouterHistory = {
length: number,
location: Location,
action: HistoryAction,
listen(
callback: (location: Location, action: HistoryAction) => void
): () => void,
push(path: string | LocationShape, state?: any): void,
replace(path: string | LocationShape, state?: any): void,
go(n: number): void,
goBack(): void,
goForward(): void,
canGo?: (n: number) => boolean,
block(
callback: string | (location: Location, action: HistoryAction) => ?string
): () => void,
// createMemoryHistory
index?: number,
entries?: Array<Location>,
...
};
declare export type Match = {
params: { [key: string]: ?string, ... },
isExact: boolean,
path: string,
url: string,
...
};
declare export type ContextRouter = {|
history: RouterHistory,
location: Location,
match: Match,
staticContext?: StaticRouterContext
|};
declare export type GetUserConfirmation = (
message: string,
callback: (confirmed: boolean) => void
) => void;
declare type StaticRouterContext = { url?: string, ... };
declare export class StaticRouter extends React$Component<{
basename?: string,
location?: string | Location,
context: StaticRouterContext,
children?: React$Node,
...
}> {}
declare export class MemoryRouter extends React$Component<{
initialEntries?: Array<LocationShape | string>,
initialIndex?: number,
getUserConfirmation?: GetUserConfirmation,
keyLength?: number,
children?: React$Node,
...
}> {}
declare export class Router extends React$Component<{
history: RouterHistory,
children?: React$Node,
...
}> {}
declare export class Prompt extends React$Component<{
message: string | ((location: Location) => string | true),
when?: boolean,
...
}> {}
declare export class Redirect extends React$Component<{|
to: string | LocationShape,
push?: boolean,
from?: string,
exact?: boolean,
strict?: boolean
|}> {}
declare export class Route extends React$Component<{|
component?: React$ComponentType<*>,
render?: (router: ContextRouter) => React$Node,
children?: React$ComponentType<ContextRouter> | React$Node,
path?: string,
exact?: boolean,
strict?: boolean,
location?: LocationShape,
sensitive?: boolean
|}> {}
declare export class Switch extends React$Component<{|
children?: React$Node,
location?: Location
|}> {}
declare export function withRouter<P>(
Component: React$ComponentType<{| ...ContextRouter, ...P |}>
): React$ComponentType<P>;
declare type MatchPathOptions = {
path?: string,
exact?: boolean,
strict?: boolean,
sensitive?: boolean,
...
};
declare export function matchPath(
pathname: string,
options?: MatchPathOptions | string
): null | Match;
}