UNPKG

1.35 kBTypeScriptView Raw
1import { Location } from "history";
2import * as React from "react";
3import { match, RouteComponentProps, SwitchProps } from "react-router";
4
5export interface RouteConfigComponentProps<Params extends { [K in keyof Params]?: string } = {}>
6 extends RouteComponentProps<Params>
7{
8 route?: RouteConfig | undefined;
9}
10
11export interface RouteConfig {
12 key?: React.Key | undefined;
13 location?: Location | undefined;
14 component?: React.ComponentType<RouteConfigComponentProps<any>> | React.ComponentType | undefined;
15 path?: string | string[] | undefined;
16 exact?: boolean | undefined;
17 strict?: boolean | undefined;
18 routes?: RouteConfig[] | undefined;
19 render?: ((props: RouteConfigComponentProps<any>) => React.ReactNode) | undefined;
20 [propName: string]: any;
21}
22
23export interface MatchedRoute<
24 Params extends { [K in keyof Params]?: string },
25 TRouteConfig extends RouteConfig = RouteConfig,
26> {
27 route: TRouteConfig;
28 match: match<Params>;
29}
30
31export function matchRoutes<
32 Params extends { [K in keyof Params]?: string },
33 TRouteConfig extends RouteConfig = RouteConfig,
34>(routes: TRouteConfig[], pathname: string): Array<MatchedRoute<Params, TRouteConfig>>;
35
36export function renderRoutes(
37 routes: RouteConfig[] | undefined,
38 extraProps?: any,
39 switchProps?: SwitchProps,
40): React.JSX.Element;
41
\No newline at end of file