UNPKG

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