react-router 6.27.0 → 6.28.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/CHANGELOG.md +21 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +57 -24
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +7 -7
- package/dist/lib/deprecations.d.ts +4 -0
- package/dist/lib/hooks.d.ts +11 -11
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +57 -24
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router.development.js +57 -23
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router v6.
|
|
2
|
+
* React Router v6.28.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
* Returns the full href for the given "to" value. This is useful for building
|
|
100
100
|
* custom links that are also accessible and preserve right-click behavior.
|
|
101
101
|
*
|
|
102
|
-
* @see https://reactrouter.com/hooks/use-href
|
|
102
|
+
* @see https://reactrouter.com/v6/hooks/use-href
|
|
103
103
|
*/
|
|
104
104
|
function useHref(to, _temp) {
|
|
105
105
|
let {
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
/**
|
|
139
139
|
* Returns true if this component is a descendant of a `<Router>`.
|
|
140
140
|
*
|
|
141
|
-
* @see https://reactrouter.com/hooks/use-in-router-context
|
|
141
|
+
* @see https://reactrouter.com/v6/hooks/use-in-router-context
|
|
142
142
|
*/
|
|
143
143
|
function useInRouterContext() {
|
|
144
144
|
return React__namespace.useContext(LocationContext) != null;
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
* "routing" in your app, and we'd like to know what your use case is. We may
|
|
153
153
|
* be able to provide something higher-level to better suit your needs.
|
|
154
154
|
*
|
|
155
|
-
* @see https://reactrouter.com/hooks/use-location
|
|
155
|
+
* @see https://reactrouter.com/v6/hooks/use-location
|
|
156
156
|
*/
|
|
157
157
|
function useLocation() {
|
|
158
158
|
!useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
* Returns the current navigation action which describes how the router came to
|
|
166
166
|
* the current location, either by a pop, push, or replace on the history stack.
|
|
167
167
|
*
|
|
168
|
-
* @see https://reactrouter.com/hooks/use-navigation-type
|
|
168
|
+
* @see https://reactrouter.com/v6/hooks/use-navigation-type
|
|
169
169
|
*/
|
|
170
170
|
function useNavigationType() {
|
|
171
171
|
return React__namespace.useContext(LocationContext).navigationType;
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
* This is useful for components that need to know "active" state, e.g.
|
|
177
177
|
* `<NavLink>`.
|
|
178
178
|
*
|
|
179
|
-
* @see https://reactrouter.com/hooks/use-match
|
|
179
|
+
* @see https://reactrouter.com/v6/hooks/use-match
|
|
180
180
|
*/
|
|
181
181
|
function useMatch(pattern) {
|
|
182
182
|
!useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
* Returns an imperative method for changing the location. Used by `<Link>`s, but
|
|
210
210
|
* may also be used by other elements to change the location.
|
|
211
211
|
*
|
|
212
|
-
* @see https://reactrouter.com/hooks/use-navigate
|
|
212
|
+
* @see https://reactrouter.com/v6/hooks/use-navigate
|
|
213
213
|
*/
|
|
214
214
|
function useNavigate() {
|
|
215
215
|
let {
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
/**
|
|
274
274
|
* Returns the context (if provided) for the child route at this level of the route
|
|
275
275
|
* hierarchy.
|
|
276
|
-
* @see https://reactrouter.com/hooks/use-outlet-context
|
|
276
|
+
* @see https://reactrouter.com/v6/hooks/use-outlet-context
|
|
277
277
|
*/
|
|
278
278
|
function useOutletContext() {
|
|
279
279
|
return React__namespace.useContext(OutletContext);
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
* Returns the element for the child route at this level of the route
|
|
284
284
|
* hierarchy. Used internally by `<Outlet>` to render child routes.
|
|
285
285
|
*
|
|
286
|
-
* @see https://reactrouter.com/hooks/use-outlet
|
|
286
|
+
* @see https://reactrouter.com/v6/hooks/use-outlet
|
|
287
287
|
*/
|
|
288
288
|
function useOutlet(context) {
|
|
289
289
|
let outlet = React__namespace.useContext(RouteContext).outlet;
|
|
@@ -299,7 +299,7 @@
|
|
|
299
299
|
* Returns an object of key/value pairs of the dynamic params from the current
|
|
300
300
|
* URL that were matched by the route path.
|
|
301
301
|
*
|
|
302
|
-
* @see https://reactrouter.com/hooks/use-params
|
|
302
|
+
* @see https://reactrouter.com/v6/hooks/use-params
|
|
303
303
|
*/
|
|
304
304
|
function useParams() {
|
|
305
305
|
let {
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
/**
|
|
313
313
|
* Resolves the pathname of the given `to` value against the current location.
|
|
314
314
|
*
|
|
315
|
-
* @see https://reactrouter.com/hooks/use-resolved-path
|
|
315
|
+
* @see https://reactrouter.com/v6/hooks/use-resolved-path
|
|
316
316
|
*/
|
|
317
317
|
function useResolvedPath(to, _temp2) {
|
|
318
318
|
let {
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
* elements in the tree must render an `<Outlet>` to render their child route's
|
|
338
338
|
* element.
|
|
339
339
|
*
|
|
340
|
-
* @see https://reactrouter.com/hooks/use-routes
|
|
340
|
+
* @see https://reactrouter.com/v6/hooks/use-routes
|
|
341
341
|
*/
|
|
342
342
|
function useRoutes(routes, locationArg) {
|
|
343
343
|
return useRoutesImpl(routes, locationArg);
|
|
@@ -712,7 +712,7 @@
|
|
|
712
712
|
return DataRouterStateHook;
|
|
713
713
|
}(DataRouterStateHook || {});
|
|
714
714
|
function getDataRouterConsoleError(hookName) {
|
|
715
|
-
return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
|
|
715
|
+
return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
|
|
716
716
|
}
|
|
717
717
|
function useDataRouterContext(hookName) {
|
|
718
718
|
let ctx = React__namespace.useContext(DataRouterContext);
|
|
@@ -942,14 +942,45 @@
|
|
|
942
942
|
}, [router$1, id]);
|
|
943
943
|
return navigate;
|
|
944
944
|
}
|
|
945
|
-
const alreadyWarned = {};
|
|
945
|
+
const alreadyWarned$1 = {};
|
|
946
946
|
function warningOnce(key, cond, message) {
|
|
947
|
-
if (!cond && !alreadyWarned[key]) {
|
|
948
|
-
alreadyWarned[key] = true;
|
|
947
|
+
if (!cond && !alreadyWarned$1[key]) {
|
|
948
|
+
alreadyWarned$1[key] = true;
|
|
949
949
|
router.UNSAFE_warning(false, message) ;
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
952
|
|
|
953
|
+
const alreadyWarned = {};
|
|
954
|
+
function warnOnce(key, message) {
|
|
955
|
+
if (!alreadyWarned[message]) {
|
|
956
|
+
alreadyWarned[message] = true;
|
|
957
|
+
console.warn(message);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
const logDeprecation = (flag, msg, link) => warnOnce(flag, "\u26A0\uFE0F React Router Future Flag Warning: " + msg + ". " + ("You can use the `" + flag + "` future flag to opt-in early. ") + ("For more information, see " + link + "."));
|
|
961
|
+
function logV6DeprecationWarnings(renderFuture, routerFuture) {
|
|
962
|
+
if (!(renderFuture != null && renderFuture.v7_startTransition)) {
|
|
963
|
+
logDeprecation("v7_startTransition", "React Router will begin wrapping state updates in `React.startTransition` in v7", "https://reactrouter.com/v6/upgrading/future#v7_starttransition");
|
|
964
|
+
}
|
|
965
|
+
if (!(renderFuture != null && renderFuture.v7_relativeSplatPath) && (!routerFuture || !routerFuture.v7_relativeSplatPath)) {
|
|
966
|
+
logDeprecation("v7_relativeSplatPath", "Relative route resolution within Splat routes is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath");
|
|
967
|
+
}
|
|
968
|
+
if (routerFuture) {
|
|
969
|
+
if (!routerFuture.v7_fetcherPersist) {
|
|
970
|
+
logDeprecation("v7_fetcherPersist", "The persistence behavior of fetchers is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist");
|
|
971
|
+
}
|
|
972
|
+
if (!routerFuture.v7_normalizeFormMethod) {
|
|
973
|
+
logDeprecation("v7_normalizeFormMethod", "Casing of `formMethod` fields is being normalized to uppercase in v7", "https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod");
|
|
974
|
+
}
|
|
975
|
+
if (!routerFuture.v7_partialHydration) {
|
|
976
|
+
logDeprecation("v7_partialHydration", "`RouterProvider` hydration behavior is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_partialhydration");
|
|
977
|
+
}
|
|
978
|
+
if (!routerFuture.v7_skipActionErrorRevalidation) {
|
|
979
|
+
logDeprecation("v7_skipActionErrorRevalidation", "The revalidation behavior after 4xx/5xx `action` responses is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation");
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
|
|
953
984
|
/**
|
|
954
985
|
Webpack + React 17 fails to compile on any of the following because webpack
|
|
955
986
|
complains that `startTransition` doesn't exist in `React`:
|
|
@@ -1026,6 +1057,7 @@
|
|
|
1026
1057
|
static: false,
|
|
1027
1058
|
basename
|
|
1028
1059
|
}), [router$1, navigator, basename]);
|
|
1060
|
+
React__namespace.useEffect(() => logV6DeprecationWarnings(future, router$1.future), [router$1, future]);
|
|
1029
1061
|
|
|
1030
1062
|
// The fragment and {null} here are important! We need them to keep React 18's
|
|
1031
1063
|
// useId happy when we are server-rendering since we may have a <script> here
|
|
@@ -1062,7 +1094,7 @@
|
|
|
1062
1094
|
/**
|
|
1063
1095
|
* A `<Router>` that stores all entries in memory.
|
|
1064
1096
|
*
|
|
1065
|
-
* @see https://reactrouter.com/router-components/memory-router
|
|
1097
|
+
* @see https://reactrouter.com/v6/router-components/memory-router
|
|
1066
1098
|
*/
|
|
1067
1099
|
function MemoryRouter(_ref3) {
|
|
1068
1100
|
let {
|
|
@@ -1092,6 +1124,7 @@
|
|
|
1092
1124
|
v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
|
|
1093
1125
|
}, [setStateImpl, v7_startTransition]);
|
|
1094
1126
|
React__namespace.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
1127
|
+
React__namespace.useEffect(() => logV6DeprecationWarnings(future), [future]);
|
|
1095
1128
|
return /*#__PURE__*/React__namespace.createElement(Router, {
|
|
1096
1129
|
basename: basename,
|
|
1097
1130
|
children: children,
|
|
@@ -1108,7 +1141,7 @@
|
|
|
1108
1141
|
* able to use hooks. In functional components, we recommend you use the
|
|
1109
1142
|
* `useNavigate` hook instead.
|
|
1110
1143
|
*
|
|
1111
|
-
* @see https://reactrouter.com/components/navigate
|
|
1144
|
+
* @see https://reactrouter.com/v6/components/navigate
|
|
1112
1145
|
*/
|
|
1113
1146
|
function Navigate(_ref4) {
|
|
1114
1147
|
let {
|
|
@@ -1147,7 +1180,7 @@
|
|
|
1147
1180
|
/**
|
|
1148
1181
|
* Renders the child route's element, if there is one.
|
|
1149
1182
|
*
|
|
1150
|
-
* @see https://reactrouter.com/components/outlet
|
|
1183
|
+
* @see https://reactrouter.com/v6/components/outlet
|
|
1151
1184
|
*/
|
|
1152
1185
|
function Outlet(props) {
|
|
1153
1186
|
return useOutlet(props.context);
|
|
@@ -1155,7 +1188,7 @@
|
|
|
1155
1188
|
/**
|
|
1156
1189
|
* Declares an element that should be rendered at a certain URL path.
|
|
1157
1190
|
*
|
|
1158
|
-
* @see https://reactrouter.com/components/route
|
|
1191
|
+
* @see https://reactrouter.com/v6/components/route
|
|
1159
1192
|
*/
|
|
1160
1193
|
function Route(_props) {
|
|
1161
1194
|
router.UNSAFE_invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, " + "never rendered directly. Please wrap your <Route> in a <Routes>.") ;
|
|
@@ -1167,7 +1200,7 @@
|
|
|
1167
1200
|
* router that is more specific to your environment such as a `<BrowserRouter>`
|
|
1168
1201
|
* in web browsers or a `<StaticRouter>` for server rendering.
|
|
1169
1202
|
*
|
|
1170
|
-
* @see https://reactrouter.com/router-components/router
|
|
1203
|
+
* @see https://reactrouter.com/v6/router-components/router
|
|
1171
1204
|
*/
|
|
1172
1205
|
function Router(_ref5) {
|
|
1173
1206
|
let {
|
|
@@ -1233,7 +1266,7 @@
|
|
|
1233
1266
|
* A container for a nested tree of `<Route>` elements that renders the branch
|
|
1234
1267
|
* that best matches the current location.
|
|
1235
1268
|
*
|
|
1236
|
-
* @see https://reactrouter.com/components/routes
|
|
1269
|
+
* @see https://reactrouter.com/v6/components/routes
|
|
1237
1270
|
*/
|
|
1238
1271
|
function Routes(_ref6) {
|
|
1239
1272
|
let {
|
|
@@ -1374,7 +1407,7 @@
|
|
|
1374
1407
|
* either a `<Route>` element or an array of them. Used internally by
|
|
1375
1408
|
* `<Routes>` to create a route config from its children.
|
|
1376
1409
|
*
|
|
1377
|
-
* @see https://reactrouter.com/utils/create-routes-from-children
|
|
1410
|
+
* @see https://reactrouter.com/v6/utils/create-routes-from-children
|
|
1378
1411
|
*/
|
|
1379
1412
|
function createRoutesFromChildren(children, parentPath) {
|
|
1380
1413
|
if (parentPath === void 0) {
|
|
@@ -1554,6 +1587,7 @@
|
|
|
1554
1587
|
exports.UNSAFE_LocationContext = LocationContext;
|
|
1555
1588
|
exports.UNSAFE_NavigationContext = NavigationContext;
|
|
1556
1589
|
exports.UNSAFE_RouteContext = RouteContext;
|
|
1590
|
+
exports.UNSAFE_logV6DeprecationWarnings = logV6DeprecationWarnings;
|
|
1557
1591
|
exports.UNSAFE_mapRouteProperties = mapRouteProperties;
|
|
1558
1592
|
exports.UNSAFE_useRouteId = useRouteId;
|
|
1559
1593
|
exports.UNSAFE_useRoutesImpl = useRoutesImpl;
|