UNPKG

5.67 kBTypeScriptView Raw
1import * as React from "react";
2import type { TrackedPromise, InitialEntry, Location, Router as RemixRouter, To, LazyRouteFunction } from "@remix-run/router";
3import { Action as NavigationType } from "@remix-run/router";
4import type { IndexRouteObject, RouteMatch, RouteObject, Navigator, NonIndexRouteObject, 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/router-components/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/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/components/outlet
48 */
49export declare function Outlet(props: OutletProps): React.ReactElement | null;
50export interface PathRouteProps {
51 caseSensitive?: NonIndexRouteObject["caseSensitive"];
52 path?: NonIndexRouteObject["path"];
53 id?: NonIndexRouteObject["id"];
54 lazy?: LazyRouteFunction<NonIndexRouteObject>;
55 loader?: NonIndexRouteObject["loader"];
56 action?: NonIndexRouteObject["action"];
57 hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
58 shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
59 handle?: NonIndexRouteObject["handle"];
60 index?: false;
61 children?: React.ReactNode;
62 element?: React.ReactNode | null;
63 errorElement?: React.ReactNode | null;
64 Component?: React.ComponentType | null;
65 ErrorBoundary?: React.ComponentType | null;
66}
67export interface LayoutRouteProps extends PathRouteProps {
68}
69export interface IndexRouteProps {
70 caseSensitive?: IndexRouteObject["caseSensitive"];
71 path?: IndexRouteObject["path"];
72 id?: IndexRouteObject["id"];
73 lazy?: LazyRouteFunction<IndexRouteObject>;
74 loader?: IndexRouteObject["loader"];
75 action?: IndexRouteObject["action"];
76 hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
77 shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
78 handle?: IndexRouteObject["handle"];
79 index: true;
80 children?: undefined;
81 element?: React.ReactNode | null;
82 errorElement?: React.ReactNode | null;
83 Component?: React.ComponentType | null;
84 ErrorBoundary?: React.ComponentType | null;
85}
86export declare type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
87/**
88 * Declares an element that should be rendered at a certain URL path.
89 *
90 * @see https://reactrouter.com/components/route
91 */
92export declare function Route(_props: RouteProps): React.ReactElement | null;
93export interface RouterProps {
94 basename?: string;
95 children?: React.ReactNode;
96 location: Partial<Location> | string;
97 navigationType?: NavigationType;
98 navigator: Navigator;
99 static?: boolean;
100}
101/**
102 * Provides location context for the rest of the app.
103 *
104 * Note: You usually won't render a <Router> directly. Instead, you'll render a
105 * router that is more specific to your environment such as a <BrowserRouter>
106 * in web browsers or a <StaticRouter> for server rendering.
107 *
108 * @see https://reactrouter.com/router-components/router
109 */
110export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
111export interface RoutesProps {
112 children?: React.ReactNode;
113 location?: Partial<Location> | string;
114}
115/**
116 * A container for a nested tree of <Route> elements that renders the branch
117 * that best matches the current location.
118 *
119 * @see https://reactrouter.com/components/routes
120 */
121export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
122export interface AwaitResolveRenderFunction {
123 (data: Awaited<any>): React.ReactNode;
124}
125export interface AwaitProps {
126 children: React.ReactNode | AwaitResolveRenderFunction;
127 errorElement?: React.ReactNode;
128 resolve: TrackedPromise | any;
129}
130/**
131 * Component to use for rendering lazily loaded data from returning defer()
132 * in a loader function
133 */
134export declare function Await({ children, errorElement, resolve }: AwaitProps): JSX.Element;
135/**
136 * Creates a route config from a React "children" object, which is usually
137 * either a `<Route>` element or an array of them. Used internally by
138 * `<Routes>` to create a route config from its children.
139 *
140 * @see https://reactrouter.com/utils/create-routes-from-children
141 */
142export declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
143/**
144 * Renders the result of `matchRoutes()` into a React element.
145 */
146export declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;