UNPKG

5.36 kBTypeScriptView Raw
1import * as React from "react";
2import type { TrackedPromise, InitialEntry, Location, Router as RemixRouter, To } from "@remix-run/router";
3import { Action as NavigationType } from "@remix-run/router";
4import type { RouteMatch, RouteObject, Navigator, RelativeRoutingType } from "./context";
5export interface RouterProviderProps {
6 fallbackElement?: React.ReactNode;
7 router: RemixRouter;
8}
9/**
10 * Given a Remix Router instance, render the appropriate UI
11 */
12export declare function RouterProvider({ fallbackElement, router, }: RouterProviderProps): React.ReactElement;
13export interface MemoryRouterProps {
14 basename?: string;
15 children?: React.ReactNode;
16 initialEntries?: InitialEntry[];
17 initialIndex?: number;
18}
19/**
20 * A <Router> that stores all entries in memory.
21 *
22 * @see https://reactrouter.com/docs/en/v6/routers/memory-router
23 */
24export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
25export interface NavigateProps {
26 to: To;
27 replace?: boolean;
28 state?: any;
29 relative?: RelativeRoutingType;
30}
31/**
32 * Changes the current location.
33 *
34 * Note: This API is mostly useful in React.Component subclasses that are not
35 * able to use hooks. In functional components, we recommend you use the
36 * `useNavigate` hook instead.
37 *
38 * @see https://reactrouter.com/docs/en/v6/components/navigate
39 */
40export declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
41export interface OutletProps {
42 context?: unknown;
43}
44/**
45 * Renders the child route's element, if there is one.
46 *
47 * @see https://reactrouter.com/docs/en/v6/components/outlet
48 */
49export declare function Outlet(props: OutletProps): React.ReactElement | null;
50interface DataRouteProps {
51 id?: RouteObject["id"];
52 loader?: RouteObject["loader"];
53 action?: RouteObject["action"];
54 errorElement?: RouteObject["errorElement"];
55 shouldRevalidate?: RouteObject["shouldRevalidate"];
56 handle?: RouteObject["handle"];
57}
58export interface RouteProps extends DataRouteProps {
59 caseSensitive?: boolean;
60 children?: React.ReactNode;
61 element?: React.ReactNode | null;
62 index?: boolean;
63 path?: string;
64}
65export interface PathRouteProps extends DataRouteProps {
66 caseSensitive?: boolean;
67 children?: React.ReactNode;
68 element?: React.ReactNode | null;
69 index?: false;
70 path: string;
71}
72export interface LayoutRouteProps extends DataRouteProps {
73 children?: React.ReactNode;
74 element?: React.ReactNode | null;
75}
76export interface IndexRouteProps extends DataRouteProps {
77 element?: React.ReactNode | null;
78 index: true;
79}
80/**
81 * Declares an element that should be rendered at a certain URL path.
82 *
83 * @see https://reactrouter.com/docs/en/v6/components/route
84 */
85export declare function Route(_props: PathRouteProps | LayoutRouteProps | IndexRouteProps): React.ReactElement | null;
86export interface RouterProps {
87 basename?: string;
88 children?: React.ReactNode;
89 location: Partial<Location> | string;
90 navigationType?: NavigationType;
91 navigator: Navigator;
92 static?: boolean;
93}
94/**
95 * Provides location context for the rest of the app.
96 *
97 * Note: You usually won't render a <Router> directly. Instead, you'll render a
98 * router that is more specific to your environment such as a <BrowserRouter>
99 * in web browsers or a <StaticRouter> for server rendering.
100 *
101 * @see https://reactrouter.com/docs/en/v6/routers/router
102 */
103export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
104export interface RoutesProps {
105 children?: React.ReactNode;
106 location?: Partial<Location> | string;
107}
108/**
109 * A container for a nested tree of <Route> elements that renders the branch
110 * that best matches the current location.
111 *
112 * @see https://reactrouter.com/docs/en/v6/components/routes
113 */
114export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
115export interface AwaitResolveRenderFunction {
116 (data: Awaited<any>): React.ReactElement;
117}
118export interface AwaitProps {
119 children: React.ReactNode | AwaitResolveRenderFunction;
120 errorElement?: React.ReactNode;
121 resolve: TrackedPromise | any;
122}
123/**
124 * Component to use for rendering lazily loaded data from returning defer()
125 * in a loader function
126 */
127export declare function Await({ children, errorElement, resolve }: AwaitProps): JSX.Element;
128/**
129 * Creates a route config from a React "children" object, which is usually
130 * either a `<Route>` element or an array of them. Used internally by
131 * `<Routes>` to create a route config from its children.
132 *
133 * @see https://reactrouter.com/docs/en/v6/utils/create-routes-from-children
134 */
135export declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
136/**
137 * Renders the result of `matchRoutes()` into a React element.
138 */
139export declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
140/**
141 * @private
142 * Walk the route tree and add hasErrorBoundary if it's not provided, so that
143 * users providing manual route arrays can just specify errorElement
144 */
145export declare function enhanceManualRouteObjects(routes: RouteObject[]): RouteObject[];
146export {};