Created
September 10, 2018 12:52
-
-
Save sagiavinash/50dfe3a5b7e68a0c9361b31e0a608ae3 to your computer and use it in GitHub Desktop.
Flow Types for React Router V4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Types for React Router V4 | |
* Example Usage: | |
* type PropsT = { | |
* myProp: string, | |
* } & ContextRouterT<{ | |
* routeParam: string, | |
* anotherRouteParam: ?string, | |
* }> | |
*/ | |
export type LocationT = { | |
pathname: string, | |
search: string, | |
hash: string, | |
state?: any, | |
key?: string, | |
}; | |
export type LocationShapeT = { | |
pathname?: string, | |
search?: string, | |
hash?: string, | |
state?: any, | |
}; | |
export type HistoryActionT = 'PUSH' | 'REPLACE' | 'POP'; | |
export type RouterHistoryT = { | |
length: number, | |
location: LocationT, | |
action: HistoryActionT, | |
listen( | |
callback: (location: LocationT, action: HistoryActionT) => void | |
): () => void, | |
push(path: string | LocationShapeT, state?: any): void, | |
replace(path: string | LocationShapeT, state?: any): void, | |
go(n: number): void, | |
goBack(): void, | |
goForward(): void, | |
canGo?: (n: number) => boolean, | |
block( | |
callback: (location: LocationT, action: HistoryActionT) => boolean | |
): void, | |
// createMemoryHistory | |
index?: number, | |
entries?: Array<LocationT>, | |
}; | |
export type MatchT<ParamsT> = { | |
params: ParamsT, | |
isExact: boolean, | |
path: string, | |
url: string, | |
}; | |
export type StaticRouterContextT = { | |
url?: string, | |
}; | |
export type ContextRouterT<ParamsT> = { | |
history: RouterHistoryT, | |
location: LocationT, | |
match: MatchT<ParamsT>, | |
staticContext?: StaticRouterContextT, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment