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