react-router 6.0.0-beta.5 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/umd/index.d.ts DELETED
@@ -1,303 +0,0 @@
1
- import * as React from "react";
2
- import { Action } from "history";
3
- import type { Blocker, History, InitialEntry, Location, Path, State, To } from "history";
4
- /**
5
- * A Navigator is a "location changer"; it's how you get to different locations.
6
- *
7
- * Every history instance conforms to the Navigator interface, but the
8
- * distinction is useful primarily when it comes to the low-level <Router> API
9
- * where both the location and a navigator must be provided separately in order
10
- * to avoid "tearing" that may occur in a suspense-enabled app if the action
11
- * and/or location were to be read directly from the history instance.
12
- */
13
- export declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen">;
14
- interface NavigationContextObject {
15
- basename: string;
16
- navigator: Navigator;
17
- static: boolean;
18
- }
19
- declare const NavigationContext: React.Context<NavigationContextObject>;
20
- interface LocationContextObject {
21
- action: Action;
22
- location: Location;
23
- }
24
- declare const LocationContext: React.Context<LocationContextObject>;
25
- declare const RouteContext: React.Context<RouteContextObject<string>>;
26
- interface RouteContextObject<ParamKey extends string = string> {
27
- outlet: React.ReactElement | null;
28
- params: Readonly<Params<ParamKey>>;
29
- pathname: string;
30
- route: RouteObject | null;
31
- }
32
- export interface MemoryRouterProps {
33
- basename?: string;
34
- children?: React.ReactNode;
35
- initialEntries?: InitialEntry[];
36
- initialIndex?: number;
37
- }
38
- /**
39
- * A <Router> that stores all entries in memory.
40
- *
41
- * @see https://reactrouter.com/api/MemoryRouter
42
- */
43
- export declare function MemoryRouter({ basename, children, initialEntries, initialIndex }: MemoryRouterProps): React.ReactElement;
44
- export interface NavigateProps {
45
- to: To;
46
- replace?: boolean;
47
- state?: State;
48
- }
49
- /**
50
- * Changes the current location.
51
- *
52
- * Note: This API is mostly useful in React.Component subclasses that are not
53
- * able to use hooks. In functional components, we recommend you use the
54
- * `useNavigate` hook instead.
55
- *
56
- * @see https://reactrouter.com/api/Navigate
57
- */
58
- export declare function Navigate({ to, replace, state }: NavigateProps): null;
59
- export interface OutletProps {
60
- }
61
- /**
62
- * Renders the child route's element, if there is one.
63
- *
64
- * @see https://reactrouter.com/api/Outlet
65
- */
66
- export declare function Outlet(_props: OutletProps): React.ReactElement | null;
67
- export interface RouteProps {
68
- caseSensitive?: boolean;
69
- children?: React.ReactNode;
70
- element?: React.ReactElement | null;
71
- index?: boolean;
72
- path?: string;
73
- }
74
- /**
75
- * Declares an element that should be rendered at a certain URL path.
76
- *
77
- * @see https://reactrouter.com/api/Route
78
- */
79
- export declare function Route(_props: RouteProps): React.ReactElement | null;
80
- export interface RouterProps {
81
- action?: Action;
82
- basename?: string;
83
- children?: React.ReactNode;
84
- location: Partial<Location> | string;
85
- navigator: Navigator;
86
- static?: boolean;
87
- }
88
- /**
89
- * Provides location context for the rest of the app.
90
- *
91
- * Note: You usually won't render a <Router> directly. Instead, you'll render a
92
- * router that is more specific to your environment such as a <BrowserRouter>
93
- * in web browsers or a <StaticRouter> for server rendering.
94
- *
95
- * @see https://reactrouter.com/api/Router
96
- */
97
- export declare function Router({ action, basename: basenameProp, children, location: locationProp, navigator, static: staticProp }: RouterProps): React.ReactElement | null;
98
- export interface RoutesProps {
99
- children?: React.ReactNode;
100
- location?: Partial<Location> | string;
101
- }
102
- /**
103
- * A container for a nested tree of <Route> elements that renders the branch
104
- * that best matches the current location.
105
- *
106
- * @see https://reactrouter.com/api/Routes
107
- */
108
- export declare function Routes({ children, location }: RoutesProps): React.ReactElement | null;
109
- /**
110
- * Blocks all navigation attempts. This is useful for preventing the page from
111
- * changing until some condition is met, like saving form data.
112
- *
113
- * @see https://reactrouter.com/api/useBlocker
114
- */
115
- export declare function useBlocker(blocker: Blocker, when?: boolean): void;
116
- /**
117
- * Returns the full href for the given "to" value. This is useful for building
118
- * custom links that are also accessible and preserve right-click behavior.
119
- *
120
- * @see https://reactrouter.com/api/useHref
121
- */
122
- export declare function useHref(to: To): string;
123
- /**
124
- * Returns true if this component is a descendant of a <Router>.
125
- *
126
- * @see https://reactrouter.com/api/useInRouterContext
127
- */
128
- export declare function useInRouterContext(): boolean;
129
- /**
130
- * Returns the current location object, which represents the current URL in web
131
- * browsers.
132
- *
133
- * Note: If you're using this it may mean you're doing some of your own
134
- * "routing" in your app, and we'd like to know what your use case is. We may
135
- * be able to provide something higher-level to better suit your needs.
136
- *
137
- * @see https://reactrouter.com/api/useLocation
138
- */
139
- export declare function useLocation(): Location;
140
- /**
141
- * Returns true if the URL for the given "to" value matches the current URL.
142
- * This is useful for components that need to know "active" state, e.g.
143
- * <NavLink>.
144
- *
145
- * @see https://reactrouter.com/api/useMatch
146
- */
147
- export declare function useMatch<ParamKey extends string = string>(pattern: PathPattern | string): PathMatch<ParamKey> | null;
148
- /**
149
- * The interface for the navigate() function returned from useNavigate().
150
- */
151
- export interface NavigateFunction {
152
- (to: To, options?: NavigateOptions): void;
153
- (delta: number): void;
154
- }
155
- export interface NavigateOptions {
156
- replace?: boolean;
157
- state?: State;
158
- }
159
- /**
160
- * Returns an imperative method for changing the location. Used by <Link>s, but
161
- * may also be used by other elements to change the location.
162
- *
163
- * @see https://reactrouter.com/api/useNavigate
164
- */
165
- export declare function useNavigate(): NavigateFunction;
166
- /**
167
- * Returns the element for the child route at this level of the route
168
- * hierarchy. Used internally by <Outlet> to render child routes.
169
- *
170
- * @see https://reactrouter.com/api/useOutlet
171
- */
172
- export declare function useOutlet(): React.ReactElement | null;
173
- /**
174
- * Returns an object of key/value pairs of the dynamic params from the current
175
- * URL that were matched by the route path.
176
- *
177
- * @see https://reactrouter.com/api/useParams
178
- */
179
- export declare function useParams<Key extends string = string>(): Readonly<Params<Key>>;
180
- /**
181
- * Resolves the pathname of the given `to` value against the current location.
182
- *
183
- * @see https://reactrouter.com/api/useResolvedPath
184
- */
185
- export declare function useResolvedPath(to: To): Path;
186
- /**
187
- * Returns the element of the route that matched the current location, prepared
188
- * with the correct context to render the remainder of the route tree. Route
189
- * elements in the tree must render an <Outlet> to render their child route's
190
- * element.
191
- *
192
- * @see https://reactrouter.com/api/useRoutes
193
- */
194
- export declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
195
- /**
196
- * Creates a route config from a React "children" object, which is usually
197
- * either a `<Route>` element or an array of them. Used internally by
198
- * `<Routes>` to create a route config from its children.
199
- *
200
- * @see https://reactrouter.com/api/createRoutesFromChildren
201
- */
202
- export declare function createRoutesFromChildren(children: React.ReactNode): RouteObject[];
203
- /**
204
- * The parameters that were parsed from the URL path.
205
- */
206
- export declare type Params<Key extends string = string> = {
207
- readonly [key in Key]: string | undefined;
208
- };
209
- /**
210
- * A route object represents a logical route, with (optionally) its child
211
- * routes organized in a tree-like structure.
212
- */
213
- export interface RouteObject {
214
- caseSensitive?: boolean;
215
- children?: RouteObject[];
216
- element?: React.ReactNode;
217
- index?: boolean;
218
- path?: string;
219
- }
220
- /**
221
- * Returns a path with params interpolated.
222
- *
223
- * @see https://reactrouter.com/api/generatePath
224
- */
225
- export declare function generatePath(path: string, params?: Params): string;
226
- /**
227
- * A RouteMatch contains info about how a route matched a URL.
228
- */
229
- export interface RouteMatch<ParamKey extends string = string> {
230
- /**
231
- * The names and values of dynamic parameters in the URL.
232
- */
233
- params: Params<ParamKey>;
234
- /**
235
- * The portion of the URL pathname that was matched.
236
- */
237
- pathname: string;
238
- /**
239
- * The route object that was used to match.
240
- */
241
- route: RouteObject;
242
- }
243
- /**
244
- * Matches the given routes to a location and returns the match data.
245
- *
246
- * @see https://reactrouter.com/api/matchRoutes
247
- */
248
- export declare function matchRoutes(routes: RouteObject[], locationArg: Partial<Location> | string, basename?: string): RouteMatch[] | null;
249
- /**
250
- * Renders the result of `matchRoutes()` into a React element.
251
- */
252
- export declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
253
- /**
254
- * A PathPattern is used to match on some portion of a URL pathname.
255
- */
256
- export interface PathPattern {
257
- /**
258
- * A string to match against a URL pathname. May contain `:id`-style segments
259
- * to indicate placeholders for dynamic parameters. May also end with `/*` to
260
- * indicate matching the rest of the URL pathname.
261
- */
262
- path: string;
263
- /**
264
- * Should be `true` if the static portions of the `path` should be matched in
265
- * the same case.
266
- */
267
- caseSensitive?: boolean;
268
- /**
269
- * Should be `true` if this pattern should match the entire URL pathname.
270
- */
271
- end?: boolean;
272
- }
273
- /**
274
- * A PathMatch contains info about how a PathPattern matched on a URL pathname.
275
- */
276
- export interface PathMatch<ParamKey extends string = string> {
277
- /**
278
- * The names and values of dynamic parameters in the URL.
279
- */
280
- params: Params<ParamKey>;
281
- /**
282
- * The portion of the URL pathname that was matched.
283
- */
284
- pathname: string;
285
- /**
286
- * The pattern that was used to match.
287
- */
288
- pattern: PathPattern;
289
- }
290
- /**
291
- * Performs pattern matching on a URL pathname and returns information about
292
- * the match.
293
- *
294
- * @see https://reactrouter.com/api/matchPath
295
- */
296
- export declare function matchPath<ParamKey extends string = string>(pattern: PathPattern | string, pathname: string): PathMatch<ParamKey> | null;
297
- /**
298
- * Returns a resolved path object relative to the given pathname.
299
- *
300
- * @see https://reactrouter.com/api/resolvePath
301
- */
302
- export declare function resolvePath(to: To, fromPathname?: string): Path;
303
- export {};