1 | import * as React from "react";
|
2 | import type { Location, ParamParseKey, Params, Path, PathMatch, PathPattern, Router as RemixRouter, To } from "@remix-run/router";
|
3 | import { Action as NavigationType } from "@remix-run/router";
|
4 | import type { NavigateOptions, RouteMatch, RouteObject, RelativeRoutingType } from "./context";
|
5 | /**
|
6 | * Returns the full href for the given "to" value. This is useful for building
|
7 | * custom links that are also accessible and preserve right-click behavior.
|
8 | *
|
9 | * @see https://reactrouter.com/docs/en/v6/hooks/use-href
|
10 | */
|
11 | export declare function useHref(to: To, { relative }?: {
|
12 | relative?: RelativeRoutingType;
|
13 | }): string;
|
14 | /**
|
15 | * Returns true if this component is a descendant of a <Router>.
|
16 | *
|
17 | * @see https://reactrouter.com/docs/en/v6/hooks/use-in-router-context
|
18 | */
|
19 | export declare function useInRouterContext(): boolean;
|
20 | /**
|
21 | * Returns the current location object, which represents the current URL in web
|
22 | * browsers.
|
23 | *
|
24 | * Note: If you're using this it may mean you're doing some of your own
|
25 | * "routing" in your app, and we'd like to know what your use case is. We may
|
26 | * be able to provide something higher-level to better suit your needs.
|
27 | *
|
28 | * @see https://reactrouter.com/docs/en/v6/hooks/use-location
|
29 | */
|
30 | export declare function useLocation(): Location;
|
31 | /**
|
32 | * Returns the current navigation action which describes how the router came to
|
33 | * the current location, either by a pop, push, or replace on the history stack.
|
34 | *
|
35 | * @see https://reactrouter.com/docs/en/v6/hooks/use-navigation-type
|
36 | */
|
37 | export declare function useNavigationType(): NavigationType;
|
38 | /**
|
39 | * Returns true if the URL for the given "to" value matches the current URL.
|
40 | * This is useful for components that need to know "active" state, e.g.
|
41 | * <NavLink>.
|
42 | *
|
43 | * @see https://reactrouter.com/docs/en/v6/hooks/use-match
|
44 | */
|
45 | export declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
|
46 | /**
|
47 | * The interface for the navigate() function returned from useNavigate().
|
48 | */
|
49 | export interface NavigateFunction {
|
50 | (to: To, options?: NavigateOptions): void;
|
51 | (delta: number): void;
|
52 | }
|
53 | /**
|
54 | * Returns an imperative method for changing the location. Used by <Link>s, but
|
55 | * may also be used by other elements to change the location.
|
56 | *
|
57 | * @see https://reactrouter.com/docs/en/v6/hooks/use-navigate
|
58 | */
|
59 | export declare function useNavigate(): NavigateFunction;
|
60 | /**
|
61 | * Returns the context (if provided) for the child route at this level of the route
|
62 | * hierarchy.
|
63 | * @see https://reactrouter.com/docs/en/v6/hooks/use-outlet-context
|
64 | */
|
65 | export declare function useOutletContext<Context = unknown>(): Context;
|
66 | /**
|
67 | * Returns the element for the child route at this level of the route
|
68 | * hierarchy. Used internally by <Outlet> to render child routes.
|
69 | *
|
70 | * @see https://reactrouter.com/docs/en/v6/hooks/use-outlet
|
71 | */
|
72 | export declare function useOutlet(context?: unknown): React.ReactElement | null;
|
73 | /**
|
74 | * Returns an object of key/value pairs of the dynamic params from the current
|
75 | * URL that were matched by the route path.
|
76 | *
|
77 | * @see https://reactrouter.com/docs/en/v6/hooks/use-params
|
78 | */
|
79 | export declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
80 | ParamsOrKey
|
81 | ] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
|
82 | /**
|
83 | * Resolves the pathname of the given `to` value against the current location.
|
84 | *
|
85 | * @see https://reactrouter.com/docs/en/v6/hooks/use-resolved-path
|
86 | */
|
87 | export declare function useResolvedPath(to: To, { relative }?: {
|
88 | relative?: RelativeRoutingType;
|
89 | }): Path;
|
90 | /**
|
91 | * Returns the element of the route that matched the current location, prepared
|
92 | * with the correct context to render the remainder of the route tree. Route
|
93 | * elements in the tree must render an <Outlet> to render their child route's
|
94 | * element.
|
95 | *
|
96 | * @see https://reactrouter.com/docs/en/v6/hooks/use-routes
|
97 | */
|
98 | export declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
99 | declare type RenderErrorBoundaryProps = React.PropsWithChildren<{
|
100 | location: Location;
|
101 | error: any;
|
102 | component: React.ReactNode;
|
103 | }>;
|
104 | declare type RenderErrorBoundaryState = {
|
105 | location: Location;
|
106 | error: any;
|
107 | };
|
108 | export declare class RenderErrorBoundary extends React.Component<RenderErrorBoundaryProps, RenderErrorBoundaryState> {
|
109 | constructor(props: RenderErrorBoundaryProps);
|
110 | static getDerivedStateFromError(error: any): {
|
111 | error: any;
|
112 | };
|
113 | static getDerivedStateFromProps(props: RenderErrorBoundaryProps, state: RenderErrorBoundaryState): {
|
114 | error: any;
|
115 | location: Location;
|
116 | };
|
117 | componentDidCatch(error: any, errorInfo: any): void;
|
118 | render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
119 | }
|
120 | export declare function _renderMatches(matches: RouteMatch[] | null, parentMatches?: RouteMatch[], dataRouterState?: RemixRouter["state"]): React.ReactElement | null;
|
121 | /**
|
122 | * Returns the current navigation, defaulting to an "idle" navigation when
|
123 | * no navigation is in progress
|
124 | */
|
125 | export declare function useNavigation(): import("). -run/router"Navigation;
|
126 | /**
|
127 | * Returns a revalidate function for manually triggering revalidation, as well
|
128 | * as the current state of any manual revalidations
|
129 | */
|
130 | export declare function useRevalidator(): {
|
131 | revalidate: () => void;
|
132 | state: import("@remix-run/router").RevalidationState;
|
133 | };
|
134 | /**
|
135 | * Returns the active route matches, useful for accessing loaderData for
|
136 | * parent/child routes or the route "handle" property
|
137 | */
|
138 | export declare function useMatches(): {
|
139 | id: string;
|
140 | pathname: string;
|
141 | params: Params<string>;
|
142 | data: unknown;
|
143 | handle: unknown;
|
144 | }[];
|
145 | /**
|
146 | * Returns the loader data for the nearest ancestor Route loader
|
147 | */
|
148 | export declare function useLoaderData(): unknown;
|
149 | /**
|
150 | * Returns the loaderData for the given routeId
|
151 | */
|
152 | export declare function useRouteLoaderData(routeId: string): unknown;
|
153 | /**
|
154 | * Returns the action data for the nearest ancestor Route action
|
155 | */
|
156 | export declare function useActionData(): unknown;
|
157 | /**
|
158 | * Returns the nearest ancestor Route error, which could be a loader/action
|
159 | * error or a render error. This is intended to be called from your
|
160 | * errorElement to display a proper error message.
|
161 | */
|
162 | export declare function useRouteError(): unknown;
|
163 | /**
|
164 | * Returns the happy-path data from the nearest ancestor <Await /> value
|
165 | */
|
166 | export declare function useAsyncValue(): unknown;
|
167 | /**
|
168 | * Returns the error from the nearest ancestor <Await /> value
|
169 | */
|
170 | export declare function useAsyncError(): unknown;
|
171 | export {};
|