1 | import * as React from "react";
|
2 | import type { Location, Path, To } from "history";
|
3 | import { Action as NavigationType } from "history";
|
4 | import type { ParamParseKey, Params, PathMatch, PathPattern, RouteMatch, RouteObject } from "./router";
|
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/api#usehref
|
10 | */
|
11 | export declare function useHref(to: To): string;
|
12 | /**
|
13 | * Returns true if this component is a descendant of a <Router>.
|
14 | *
|
15 | * @see https://reactrouter.com/docs/en/v6/api#useinroutercontext
|
16 | */
|
17 | export declare function useInRouterContext(): boolean;
|
18 | /**
|
19 | * Returns the current location object, which represents the current URL in web
|
20 | * browsers.
|
21 | *
|
22 | * Note: If you're using this it may mean you're doing some of your own
|
23 | * "routing" in your app, and we'd like to know what your use case is. We may
|
24 | * be able to provide something higher-level to better suit your needs.
|
25 | *
|
26 | * @see https://reactrouter.com/docs/en/v6/api#uselocation
|
27 | */
|
28 | export declare function useLocation(): Location;
|
29 | /**
|
30 | * Returns the current navigation action which describes how the router came to
|
31 | * the current location, either by a pop, push, or replace on the history stack.
|
32 | *
|
33 | * @see https://reactrouter.com/docs/en/v6/api#usenavigationtype
|
34 | */
|
35 | export declare function useNavigationType(): NavigationType;
|
36 | /**
|
37 | * Returns true if the URL for the given "to" value matches the current URL.
|
38 | * This is useful for components that need to know "active" state, e.g.
|
39 | * <NavLink>.
|
40 | *
|
41 | * @see https://reactrouter.com/docs/en/v6/api#usematch
|
42 | */
|
43 | export declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
|
44 | /**
|
45 | * The interface for the navigate() function returned from useNavigate().
|
46 | */
|
47 | export interface NavigateFunction {
|
48 | (to: To, options?: NavigateOptions): void;
|
49 | (delta: number): void;
|
50 | }
|
51 | export interface NavigateOptions {
|
52 | replace?: boolean;
|
53 | state?: any;
|
54 | }
|
55 | /**
|
56 | * Returns an imperative method for changing the location. Used by <Link>s, but
|
57 | * may also be used by other elements to change the location.
|
58 | *
|
59 | * @see https://reactrouter.com/docs/en/v6/api#usenavigate
|
60 | */
|
61 | export declare function useNavigate(): NavigateFunction;
|
62 | /**
|
63 | * Returns the context (if provided) for the child route at this level of the route
|
64 | * hierarchy.
|
65 | * @see https://reactrouter.com/docs/en/v6/api#useoutletcontext
|
66 | */
|
67 | export declare function useOutletContext<Context = unknown>(): Context;
|
68 | /**
|
69 | * Returns the element for the child route at this level of the route
|
70 | * hierarchy. Used internally by <Outlet> to render child routes.
|
71 | *
|
72 | * @see https://reactrouter.com/docs/en/v6/api#useoutlet
|
73 | */
|
74 | export declare function useOutlet(context?: unknown): React.ReactElement | null;
|
75 | /**
|
76 | * Returns an object of key/value pairs of the dynamic params from the current
|
77 | * URL that were matched by the route path.
|
78 | *
|
79 | * @see https://reactrouter.com/docs/en/v6/api#useparams
|
80 | */
|
81 | export declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
|
82 | ParamsOrKey
|
83 | ] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
|
84 | /**
|
85 | * Resolves the pathname of the given `to` value against the current location.
|
86 | *
|
87 | * @see https://reactrouter.com/docs/en/v6/api#useresolvedpath
|
88 | */
|
89 | export declare function useResolvedPath(to: To): 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/api#useroutes
|
97 | */
|
98 | export declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
|
99 | export declare function _renderMatches(matches: RouteMatch[] | null, parentMatches?: RouteMatch[]): React.ReactElement | null;
|