UNPKG

3.82 kBTypeScriptView Raw
1import * as React from "react";
2import type { InitialEntry, Location, To } from "history";
3import { Action as NavigationType } from "history";
4import { Navigator } from "./context";
5import type { RouteMatch, RouteObject } from "./router";
6export interface MemoryRouterProps {
7 basename?: string;
8 children?: React.ReactNode;
9 initialEntries?: InitialEntry[];
10 initialIndex?: number;
11}
12/**
13 * A <Router> that stores all entries in memory.
14 *
15 * @see https://reactrouter.com/docs/en/v6/api#memoryrouter
16 */
17export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
18export interface NavigateProps {
19 to: To;
20 replace?: boolean;
21 state?: any;
22}
23/**
24 * Changes the current location.
25 *
26 * Note: This API is mostly useful in React.Component subclasses that are not
27 * able to use hooks. In functional components, we recommend you use the
28 * `useNavigate` hook instead.
29 *
30 * @see https://reactrouter.com/docs/en/v6/api#navigate
31 */
32export declare function Navigate({ to, replace, state }: NavigateProps): null;
33export interface OutletProps {
34 context?: unknown;
35}
36/**
37 * Renders the child route's element, if there is one.
38 *
39 * @see https://reactrouter.com/docs/en/v6/api#outlet
40 */
41export declare function Outlet(props: OutletProps): React.ReactElement | null;
42export interface RouteProps {
43 caseSensitive?: boolean;
44 children?: React.ReactNode;
45 element?: React.ReactNode | null;
46 index?: boolean;
47 path?: string;
48}
49export interface PathRouteProps {
50 caseSensitive?: boolean;
51 children?: React.ReactNode;
52 element?: React.ReactNode | null;
53 index?: false;
54 path: string;
55}
56export interface LayoutRouteProps {
57 children?: React.ReactNode;
58 element?: React.ReactNode | null;
59}
60export interface IndexRouteProps {
61 element?: React.ReactNode | null;
62 index: true;
63}
64/**
65 * Declares an element that should be rendered at a certain URL path.
66 *
67 * @see https://reactrouter.com/docs/en/v6/api#route
68 */
69export declare function Route(_props: PathRouteProps | LayoutRouteProps | IndexRouteProps): React.ReactElement | null;
70export interface RouterProps {
71 basename?: string;
72 children?: React.ReactNode;
73 location: Partial<Location> | string;
74 navigationType?: NavigationType;
75 navigator: Navigator;
76 static?: boolean;
77}
78/**
79 * Provides location context for the rest of the app.
80 *
81 * Note: You usually won't render a <Router> directly. Instead, you'll render a
82 * router that is more specific to your environment such as a <BrowserRouter>
83 * in web browsers or a <StaticRouter> for server rendering.
84 *
85 * @see https://reactrouter.com/docs/en/v6/api#router
86 */
87export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
88export interface RoutesProps {
89 children?: React.ReactNode;
90 location?: Partial<Location> | string;
91}
92/**
93 * A container for a nested tree of <Route> elements that renders the branch
94 * that best matches the current location.
95 *
96 * @see https://reactrouter.com/docs/en/v6/api#routes
97 */
98export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
99/**
100 * Creates a route config from a React "children" object, which is usually
101 * either a `<Route>` element or an array of them. Used internally by
102 * `<Routes>` to create a route config from its children.
103 *
104 * @see https://reactrouter.com/docs/en/v6/api#createroutesfromchildren
105 */
106export declare function createRoutesFromChildren(children: React.ReactNode): RouteObject[];
107/**
108 * Renders the result of `matchRoutes()` into a React element.
109 */
110export declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;