UNPKG

1.91 kBTypeScriptView Raw
1import { History, Location, LocationDescriptor, LocationState, Path } from "history";
2import * as React from "react";
3import { match } from "react-router";
4import { Dispatch, Middleware, Reducer, Store } from "redux";
5
6export interface ConnectedRouterProps<State> {
7 children?: React.ReactNode;
8 store?: Store<State> | undefined;
9 history: History;
10}
11export class ConnectedRouter<State> extends React.Component<ConnectedRouterProps<State>> {}
12
13export const LOCATION_CHANGE = "@@router/LOCATION_CHANGE";
14
15export interface RouterState {
16 location: Location | null;
17}
18
19export const routerReducer: Reducer<RouterState>;
20
21export const CALL_HISTORY_METHOD = "@@router/CALL_HISTORY_METHOD";
22
23export function push(location: LocationDescriptor, state?: LocationState): RouterAction;
24export function replace(location: LocationDescriptor, state?: LocationState): RouterAction;
25export function go(n: number): RouterAction;
26export function goBack(): RouterAction;
27export function goForward(): RouterAction;
28
29export const routerActions: {
30 push: typeof push;
31 replace: typeof replace;
32 go: typeof go;
33 goBack: typeof goBack;
34 goForward: typeof goForward;
35};
36
37export interface LocationActionPayload {
38 method: string;
39 args?: any[] | undefined;
40}
41
42export interface RouterAction {
43 type: typeof CALL_HISTORY_METHOD;
44 payload: LocationActionPayload;
45}
46
47export interface LocationChangeAction {
48 type: typeof LOCATION_CHANGE;
49 payload: Location & {
50 props?: {
51 match: {
52 path: string;
53 url: string;
54 params: any;
55 isExact: boolean;
56 };
57 location: Location;
58 history: History;
59 } | undefined;
60 };
61}
62
63export function routerMiddleware(history: History): Middleware;
64
65export function createMatchSelector(path: string): (state: { router: RouterState }) => match | null;