UNPKG

2.32 kBTypeScriptView Raw
1// Type definitions for react-router-redux 5.0
2// Project: https://github.com/reactjs/react-router-redux
3// Definitions by: Huy Nguyen <https://github.com/huy-nguyen>
4// Shoya Tanaka <https://github.com/8398a7>
5// Mykolas <https://github.com/mykolas>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7// TypeScript Version: 3.0
8
9import {
10 Store,
11 Dispatch,
12 Middleware,
13 Reducer
14} from 'redux';
15import {
16 History,
17 Location,
18 Path,
19 LocationState,
20 LocationDescriptor
21} from 'history';
22import * as React from 'react';
23import { match } from 'react-router';
24
25export interface ConnectedRouterProps<State> {
26 children?: React.ReactNode;
27 store?: Store<State> | undefined;
28 history: History;
29}
30export class ConnectedRouter<State> extends React.Component<ConnectedRouterProps<State>> {}
31
32export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
33
34export interface RouterState {
35 location: Location | null;
36}
37
38export const routerReducer: Reducer<RouterState>;
39
40export const CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD';
41
42export function push(location: LocationDescriptor, state?: LocationState): RouterAction;
43export function replace(location: LocationDescriptor, state?: LocationState): RouterAction;
44export function go(n: number): RouterAction;
45export function goBack(): RouterAction;
46export function goForward(): RouterAction;
47
48export const routerActions: {
49 push: typeof push
50 replace: typeof replace
51 go: typeof go
52 goBack: typeof goBack
53 goForward: typeof goForward
54};
55
56export interface LocationActionPayload {
57 method: string;
58 args?: any[] | undefined;
59}
60
61export interface RouterAction {
62 type: typeof CALL_HISTORY_METHOD;
63 payload: LocationActionPayload;
64}
65
66export interface LocationChangeAction {
67 type: typeof LOCATION_CHANGE;
68 payload: Location & {
69 props?: {
70 match: {
71 path: string;
72 url: string;
73 params: any;
74 isExact: boolean;
75 },
76 location: Location;
77 history: History;
78 } | undefined
79 };
80}
81
82export function routerMiddleware(history: History): Middleware;
83
84export function createMatchSelector(path: string): (state: { router: RouterState }) => match | null;