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/{LICENSE → LICENSE.md} +0 -0
- package/index.d.ts +45 -22
- package/index.js +223 -160
- package/index.js.map +1 -1
- package/main.js +10 -0
- package/package.json +8 -6
- package/react-router.development.js +217 -138
- package/react-router.development.js.map +1 -1
- package/react-router.production.min.js +11 -1
- package/react-router.production.min.js.map +1 -1
- package/umd/react-router.development.js +223 -160
- package/umd/react-router.development.js.map +1 -1
- package/umd/react-router.production.min.js +11 -1
- package/umd/react-router.production.min.js.map +1 -1
- package/umd/index.d.ts +0 -303
package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import type { History, InitialEntry, Location, Path, To } from "history";
|
|
3
|
+
import { Action as NavigationType } from "history";
|
|
4
|
+
export type { Location, Path, To, NavigationType };
|
|
4
5
|
/**
|
|
5
6
|
* A Navigator is a "location changer"; it's how you get to different locations.
|
|
6
7
|
*
|
|
@@ -10,7 +11,7 @@ import type { Blocker, History, InitialEntry, Location, Path, State, To } from "
|
|
|
10
11
|
* to avoid "tearing" that may occur in a suspense-enabled app if the action
|
|
11
12
|
* and/or location were to be read directly from the history instance.
|
|
12
13
|
*/
|
|
13
|
-
export declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen">;
|
|
14
|
+
export declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen" | "block">;
|
|
14
15
|
interface NavigationContextObject {
|
|
15
16
|
basename: string;
|
|
16
17
|
navigator: Navigator;
|
|
@@ -18,17 +19,15 @@ interface NavigationContextObject {
|
|
|
18
19
|
}
|
|
19
20
|
declare const NavigationContext: React.Context<NavigationContextObject>;
|
|
20
21
|
interface LocationContextObject {
|
|
21
|
-
action: Action;
|
|
22
22
|
location: Location;
|
|
23
|
+
navigationType: NavigationType;
|
|
23
24
|
}
|
|
24
25
|
declare const LocationContext: React.Context<LocationContextObject>;
|
|
25
|
-
|
|
26
|
-
interface RouteContextObject<ParamKey extends string = string> {
|
|
26
|
+
interface RouteContextObject {
|
|
27
27
|
outlet: React.ReactElement | null;
|
|
28
|
-
|
|
29
|
-
pathname: string;
|
|
30
|
-
route: RouteObject | null;
|
|
28
|
+
matches: RouteMatch[];
|
|
31
29
|
}
|
|
30
|
+
declare const RouteContext: React.Context<RouteContextObject>;
|
|
32
31
|
export interface MemoryRouterProps {
|
|
33
32
|
basename?: string;
|
|
34
33
|
children?: React.ReactNode;
|
|
@@ -44,7 +43,7 @@ export declare function MemoryRouter({ basename, children, initialEntries, initi
|
|
|
44
43
|
export interface NavigateProps {
|
|
45
44
|
to: To;
|
|
46
45
|
replace?: boolean;
|
|
47
|
-
state?:
|
|
46
|
+
state?: any;
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
49
|
* Changes the current location.
|
|
@@ -71,17 +70,32 @@ export interface RouteProps {
|
|
|
71
70
|
index?: boolean;
|
|
72
71
|
path?: string;
|
|
73
72
|
}
|
|
73
|
+
export interface PathRouteProps {
|
|
74
|
+
caseSensitive?: boolean;
|
|
75
|
+
children?: React.ReactNode;
|
|
76
|
+
element?: React.ReactElement | null;
|
|
77
|
+
index?: false;
|
|
78
|
+
path: string;
|
|
79
|
+
}
|
|
80
|
+
export interface LayoutRouteProps {
|
|
81
|
+
children?: React.ReactNode;
|
|
82
|
+
element?: React.ReactElement | null;
|
|
83
|
+
}
|
|
84
|
+
export interface IndexRouteProps {
|
|
85
|
+
element?: React.ReactElement | null;
|
|
86
|
+
index: true;
|
|
87
|
+
}
|
|
74
88
|
/**
|
|
75
89
|
* Declares an element that should be rendered at a certain URL path.
|
|
76
90
|
*
|
|
77
91
|
* @see https://reactrouter.com/api/Route
|
|
78
92
|
*/
|
|
79
|
-
export declare function Route(_props:
|
|
93
|
+
export declare function Route(_props: PathRouteProps | LayoutRouteProps | IndexRouteProps): React.ReactElement | null;
|
|
80
94
|
export interface RouterProps {
|
|
81
|
-
action?: Action;
|
|
82
95
|
basename?: string;
|
|
83
96
|
children?: React.ReactNode;
|
|
84
97
|
location: Partial<Location> | string;
|
|
98
|
+
navigationType?: NavigationType;
|
|
85
99
|
navigator: Navigator;
|
|
86
100
|
static?: boolean;
|
|
87
101
|
}
|
|
@@ -94,7 +108,7 @@ export interface RouterProps {
|
|
|
94
108
|
*
|
|
95
109
|
* @see https://reactrouter.com/api/Router
|
|
96
110
|
*/
|
|
97
|
-
export declare function Router({
|
|
111
|
+
export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp }: RouterProps): React.ReactElement | null;
|
|
98
112
|
export interface RoutesProps {
|
|
99
113
|
children?: React.ReactNode;
|
|
100
114
|
location?: Partial<Location> | string;
|
|
@@ -106,13 +120,6 @@ export interface RoutesProps {
|
|
|
106
120
|
* @see https://reactrouter.com/api/Routes
|
|
107
121
|
*/
|
|
108
122
|
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
123
|
/**
|
|
117
124
|
* Returns the full href for the given "to" value. This is useful for building
|
|
118
125
|
* custom links that are also accessible and preserve right-click behavior.
|
|
@@ -137,6 +144,13 @@ export declare function useInRouterContext(): boolean;
|
|
|
137
144
|
* @see https://reactrouter.com/api/useLocation
|
|
138
145
|
*/
|
|
139
146
|
export declare function useLocation(): Location;
|
|
147
|
+
/**
|
|
148
|
+
* Returns the current navigation action which describes how the router came to
|
|
149
|
+
* the current location, either by a pop, push, or replace on the history stack.
|
|
150
|
+
*
|
|
151
|
+
* @see https://reactrouter.com/api/useNavigationType
|
|
152
|
+
*/
|
|
153
|
+
export declare function useNavigationType(): NavigationType;
|
|
140
154
|
/**
|
|
141
155
|
* Returns true if the URL for the given "to" value matches the current URL.
|
|
142
156
|
* This is useful for components that need to know "active" state, e.g.
|
|
@@ -154,7 +168,7 @@ export interface NavigateFunction {
|
|
|
154
168
|
}
|
|
155
169
|
export interface NavigateOptions {
|
|
156
170
|
replace?: boolean;
|
|
157
|
-
state?:
|
|
171
|
+
state?: any;
|
|
158
172
|
}
|
|
159
173
|
/**
|
|
160
174
|
* Returns an imperative method for changing the location. Used by <Link>s, but
|
|
@@ -235,6 +249,10 @@ export interface RouteMatch<ParamKey extends string = string> {
|
|
|
235
249
|
* The portion of the URL pathname that was matched.
|
|
236
250
|
*/
|
|
237
251
|
pathname: string;
|
|
252
|
+
/**
|
|
253
|
+
* The portion of the URL pathname that was matched before child routes.
|
|
254
|
+
*/
|
|
255
|
+
pathnameBase: string;
|
|
238
256
|
/**
|
|
239
257
|
* The route object that was used to match.
|
|
240
258
|
*/
|
|
@@ -282,6 +300,10 @@ export interface PathMatch<ParamKey extends string = string> {
|
|
|
282
300
|
* The portion of the URL pathname that was matched.
|
|
283
301
|
*/
|
|
284
302
|
pathname: string;
|
|
303
|
+
/**
|
|
304
|
+
* The portion of the URL pathname that was matched before child routes.
|
|
305
|
+
*/
|
|
306
|
+
pathnameBase: string;
|
|
285
307
|
/**
|
|
286
308
|
* The pattern that was used to match.
|
|
287
309
|
*/
|
|
@@ -300,4 +322,5 @@ export declare function matchPath<ParamKey extends string = string>(pattern: Pat
|
|
|
300
322
|
* @see https://reactrouter.com/api/resolvePath
|
|
301
323
|
*/
|
|
302
324
|
export declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
303
|
-
|
|
325
|
+
/** @internal */
|
|
326
|
+
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext };
|