moira-web

Форк
0
/
react-router-dom_v4.x.x.js.flow 
168 строк · 4.4 Кб
1
declare module 'react-router-dom' {
2
    declare type BrowserRouterProps = {
3
        basename?: string,
4
        forceRefresh?: boolean,
5
        getUserConfirmation?: GetUserConfirmation,
6
        keyLength?: number,
7
        children?: React$Element<*>,
8
    };
9

10
    declare export class BrowserRouter extends React$Component<BrowserRouterProps> {
11
        props: BrowserRouterProps;
12
    }
13

14
  declare export class HashRouter extends React$Component<*> {
15
    props: {
16
      basename?: string,
17
      getUserConfirmation?: GetUserConfirmation,
18
      hashType?: 'slash' | 'noslash' | 'hashbang',
19
      children?: React$Element<*>,
20
    }
21
  }
22

23
  declare export class Link extends React$Component<*> {
24
    props: {
25
      to?: string | LocationShape,
26
      replace?: boolean,
27
      children?: React$Element<*>,
28
    }
29
  }
30

31
  declare export class NavLink extends React$Component<*> {
32
    props: {
33
      to: string | LocationShape,
34
      activeClassName?: string,
35
      className?: string,
36
      activeStyle?: Object,
37
      style?: Object,
38
      isActive?: (match: Match, location: Location) => boolean,
39
      children?: React$Element<*>,
40
      exact?: bool,
41
      strict?: bool,
42
    }
43
  }
44

45
  // NOTE: Below are duplicated from react-router. If updating these, please
46
  // update the react-router and react-router-native types as well.
47
  declare export type Location = {
48
    pathname: string,
49
    search: string,
50
    hash: string,
51
    state?: any,
52
    key?: string,
53
  }
54

55
  declare export type LocationShape = {
56
    pathname?: string,
57
    search?: string,
58
    hash?: string,
59
    state?: any,
60
  }
61

62
  declare export type HistoryAction = 'PUSH' | 'REPLACE' | 'POP'
63

64
  declare export type RouterHistory = {
65
    length: number,
66
    location: Location,
67
    action: HistoryAction,
68
    listen(callback: (location: Location, action: HistoryAction) => void): () => void,
69
    push(path: string | LocationShape, state?: any): void,
70
    replace(path: string | LocationShape, state?: any): void,
71
    go(n: number): void,
72
    goBack(): void,
73
    goForward(): void,
74
    canGo?: (n: number) => bool,
75
    block(callback: (location: Location, action: HistoryAction) => boolean): void,
76
    // createMemoryHistory
77
    index?: number,
78
    entries?: Array<Location>,
79
  }
80

81
  declare export type Match = {
82
    params: { [key: string]: ?string },
83
    isExact: boolean,
84
    path: string,
85
    url: string,
86
  }
87

88
  declare export type ContextRouter = {
89
    history: RouterHistory,
90
    location: Location,
91
    match: Match,
92
  }
93

94
  declare export type GetUserConfirmation =
95
    (message: string, callback: (confirmed: boolean) => void) => void
96

97
  declare type StaticRouterContext = {
98
    url?: string,
99
  }
100

101
  declare export class StaticRouter extends React$Component<*> {
102
    props: {
103
      basename?: string,
104
      location?: string | Location,
105
      context: StaticRouterContext,
106
      children?: React$Element<*>,
107
    }
108
  }
109

110
  declare export class MemoryRouter extends React$Component<*> {
111
    props: {
112
      initialEntries?: Array<LocationShape | string>,
113
      initialIndex?: number,
114
      getUserConfirmation?: GetUserConfirmation,
115
      keyLength?: number,
116
      children?: React$Element<*>,
117
    }
118
  }
119

120
  declare export class Router extends React$Component<*> {
121
    props: {
122
      history: RouterHistory,
123
      children?: React$Element<*>,
124
    }
125
  }
126

127
  declare export class Prompt extends React$Component<*> {
128
    props: {
129
      message: string | (location: Location) => string | true,
130
      when?: boolean,
131
    }
132
  }
133

134
  declare export class Redirect extends React$Component<*> {
135
    props: {
136
      to: string | LocationShape,
137
      push?: boolean,
138
    }
139
  }
140

141
  declare export class Route extends React$Component<*> {
142
    props: {
143
      component?: React$ComponentType<any>,
144
      render?: (router: ContextRouter) => React$Element<*>,
145
      children?: (router: ContextRouter) => React$Element<*>,
146
      path?: string,
147
      exact?: bool,
148
      strict?: bool,
149
    }
150
  }
151

152
  declare export class Switch extends React$Component<*> {
153
    props: {
154
      children?: Array<React$Element<*>>,
155
    }
156
  }
157

158
  declare type FunctionComponent<P> = (props: P) => ?React$Element<any>;
159
  declare type ClassComponent<D, P, S> = Class<React$Component<D, P, S>>;
160
  declare export function withRouter<P, S>(Component: ClassComponent<void, P, S> | FunctionComponent<P>): ClassComponent<void, $Diff<P, ContextRouter>, S>;
161

162
  declare type MatchPathOptions = {
163
    path: string,
164
    exact?: boolean,
165
    strict?: boolean,
166
  }
167
  declare export function matchPath(pathname: string, options: MatchPathOptions): null | Match
168
}
169

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.