|
| 1 | +// flow-typed signature: 4d8e947f2e396ef2f26ecbd1ed7f04ab |
| 2 | +// flow-typed version: 97d98ab83e/react-router-dom_v4.x.x/flow_>=v0.53.x |
| 3 | + |
| 4 | +declare module 'react-router-dom' { |
| 5 | + declare export class BrowserRouter extends React$Component<{ |
| 6 | + basename?: string, |
| 7 | + forceRefresh?: boolean, |
| 8 | + getUserConfirmation?: GetUserConfirmation, |
| 9 | + keyLength?: number, |
| 10 | + children?: React$Node, |
| 11 | + }> {} |
| 12 | + |
| 13 | + declare export class HashRouter extends React$Component<{ |
| 14 | + basename?: string, |
| 15 | + getUserConfirmation?: GetUserConfirmation, |
| 16 | + hashType?: 'slash' | 'noslash' | 'hashbang', |
| 17 | + children?: React$Node, |
| 18 | + }> {} |
| 19 | + |
| 20 | + declare export class Link extends React$Component<{ |
| 21 | + to: string | LocationShape, |
| 22 | + replace?: boolean, |
| 23 | + children?: React$Node, |
| 24 | + }> {} |
| 25 | + |
| 26 | + declare export class NavLink extends React$Component<{ |
| 27 | + to: string | LocationShape, |
| 28 | + activeClassName?: string, |
| 29 | + className?: string, |
| 30 | + activeStyle?: Object, |
| 31 | + style?: Object, |
| 32 | + isActive?: (match: Match, location: Location) => boolean, |
| 33 | + children?: React$Node, |
| 34 | + exact?: boolean, |
| 35 | + strict?: boolean, |
| 36 | + }> {} |
| 37 | + |
| 38 | + // NOTE: Below are duplicated from react-router. If updating these, please |
| 39 | + // update the react-router and react-router-native types as well. |
| 40 | + declare export type Location = { |
| 41 | + pathname: string, |
| 42 | + search: string, |
| 43 | + hash: string, |
| 44 | + state?: any, |
| 45 | + key?: string, |
| 46 | + }; |
| 47 | + |
| 48 | + declare export type LocationShape = { |
| 49 | + pathname?: string, |
| 50 | + search?: string, |
| 51 | + hash?: string, |
| 52 | + state?: any, |
| 53 | + }; |
| 54 | + |
| 55 | + declare export type HistoryAction = 'PUSH' | 'REPLACE' | 'POP'; |
| 56 | + |
| 57 | + declare export type RouterHistory = { |
| 58 | + length: number, |
| 59 | + location: Location, |
| 60 | + action: HistoryAction, |
| 61 | + listen(callback: (location: Location, action: HistoryAction) => void): () => void, |
| 62 | + push(path: string | LocationShape, state?: any): void, |
| 63 | + replace(path: string | LocationShape, state?: any): void, |
| 64 | + go(n: number): void, |
| 65 | + goBack(): void, |
| 66 | + goForward(): void, |
| 67 | + canGo?: (n: number) => boolean, |
| 68 | + block(callback: (location: Location, action: HistoryAction) => boolean): void, |
| 69 | + // createMemoryHistory |
| 70 | + index?: number, |
| 71 | + entries?: Array<Location>, |
| 72 | + }; |
| 73 | + |
| 74 | + declare export type Match = { |
| 75 | + params: { [key: string]: ?string }, |
| 76 | + isExact: boolean, |
| 77 | + path: string, |
| 78 | + url: string, |
| 79 | + }; |
| 80 | + |
| 81 | + declare export type ContextRouter = {| |
| 82 | + history: RouterHistory, |
| 83 | + location: Location, |
| 84 | + match: Match, |
| 85 | + |}; |
| 86 | + |
| 87 | + declare export type GetUserConfirmation = (message: string, callback: (confirmed: boolean) => void) => void; |
| 88 | + |
| 89 | + declare type StaticRouterContext = { |
| 90 | + url?: string, |
| 91 | + }; |
| 92 | + |
| 93 | + declare export class StaticRouter extends React$Component<{ |
| 94 | + basename?: string, |
| 95 | + location?: string | Location, |
| 96 | + context: StaticRouterContext, |
| 97 | + children?: React$Node, |
| 98 | + }> {} |
| 99 | + |
| 100 | + declare export class MemoryRouter extends React$Component<{ |
| 101 | + initialEntries?: Array<LocationShape | string>, |
| 102 | + initialIndex?: number, |
| 103 | + getUserConfirmation?: GetUserConfirmation, |
| 104 | + keyLength?: number, |
| 105 | + children?: React$Node, |
| 106 | + }> {} |
| 107 | + |
| 108 | + declare export class Router extends React$Component<{ |
| 109 | + history: RouterHistory, |
| 110 | + children?: React$Node, |
| 111 | + }> {} |
| 112 | + |
| 113 | + declare export class Prompt extends React$Component<{ |
| 114 | + message: string | ((location: Location) => string | true), |
| 115 | + when?: boolean, |
| 116 | + }> {} |
| 117 | + |
| 118 | + declare export class Redirect extends React$Component<{ |
| 119 | + to: string | LocationShape, |
| 120 | + push?: boolean, |
| 121 | + }> {} |
| 122 | + |
| 123 | + declare export class Route extends React$Component<{ |
| 124 | + component?: React$ComponentType<*>, |
| 125 | + render?: (router: ContextRouter) => React$Node, |
| 126 | + children?: React$ComponentType<ContextRouter> | React$Node, |
| 127 | + path?: string, |
| 128 | + exact?: boolean, |
| 129 | + strict?: boolean, |
| 130 | + }> {} |
| 131 | + |
| 132 | + declare export class Switch extends React$Component<{ |
| 133 | + children?: React$Node, |
| 134 | + }> {} |
| 135 | + |
| 136 | + declare export function withRouter<P>( |
| 137 | + Component: React$ComponentType<{| ...ContextRouter, ...P |}> |
| 138 | + ): React$ComponentType<P>; |
| 139 | + |
| 140 | + declare type MatchPathOptions = { |
| 141 | + path?: string, |
| 142 | + exact?: boolean, |
| 143 | + sensitive?: boolean, |
| 144 | + strict?: boolean, |
| 145 | + }; |
| 146 | + |
| 147 | + declare export function matchPath(pathname: string, options?: MatchPathOptions | string): null | Match; |
| 148 | +} |
0 commit comments