react-router 0.0.0-experimental-63b6834e → 0.0.0-experimental-ba938b84
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 +18 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.js +73 -49
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +7 -3
- package/dist/lib/context.d.ts +1 -3
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +51 -26
- 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 +66 -41
- 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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 6.8.2-pre.3
|
|
4
|
+
|
|
5
|
+
## 6.8.2-pre.2
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- Updated dependencies:
|
|
10
|
+
- `@remix-run/router@1.3.3-pre.1`
|
|
11
|
+
|
|
12
|
+
## 6.8.2-pre.1
|
|
13
|
+
|
|
14
|
+
## 6.8.2-pre.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies:
|
|
19
|
+
- `@remix-run/router@1.3.3-pre.0`
|
|
20
|
+
|
|
3
21
|
## 6.8.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, Fetcher, HydrationState, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, Router as RemixRouter, ShouldRevalidateFunction, To, InitialEntry
|
|
1
|
+
import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, Fetcher, HydrationState, JsonFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, Router as RemixRouter, ShouldRevalidateFunction, To, InitialEntry } from "@remix-run/router";
|
|
2
2
|
import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from "@remix-run/router";
|
|
3
3
|
import type { AwaitProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps, RouterProviderProps } from "./lib/components";
|
|
4
|
-
import { createRoutesFromChildren, renderMatches, Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes } from "./lib/components";
|
|
4
|
+
import { enhanceManualRouteObjects, createRoutesFromChildren, renderMatches, Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes } from "./lib/components";
|
|
5
5
|
import type { DataRouteMatch, DataRouteObject, IndexRouteObject, Navigator, NavigateOptions, NonIndexRouteObject, RouteMatch, RouteObject, RelativeRoutingType } from "./lib/context";
|
|
6
6
|
import { DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
|
|
7
7
|
import type { NavigateFunction } from "./lib/hooks";
|
|
@@ -9,16 +9,13 @@ import { useBlocker, useHref, useInRouterContext, useLocation, useMatch, useNavi
|
|
|
9
9
|
declare type Hash = string;
|
|
10
10
|
declare type Pathname = string;
|
|
11
11
|
declare type Search = string;
|
|
12
|
-
export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker as unstable_Blocker, BlockerFunction as unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction,
|
|
12
|
+
export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker as unstable_Blocker, BlockerFunction as unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
|
|
13
13
|
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useBlocker as unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
|
|
14
14
|
export declare function createMemoryRouter(routes: RouteObject[], opts?: {
|
|
15
15
|
basename?: string;
|
|
16
16
|
hydrationData?: HydrationState;
|
|
17
17
|
initialEntries?: InitialEntry[];
|
|
18
18
|
initialIndex?: number;
|
|
19
|
-
onInitialize?: (args: {
|
|
20
|
-
router: RemixRouter;
|
|
21
|
-
}) => void;
|
|
22
19
|
}): RemixRouter;
|
|
23
20
|
/** @internal */
|
|
24
|
-
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, };
|
|
21
|
+
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router v0.0.0-experimental-
|
|
2
|
+
* React Router v0.0.0-experimental-ba938b84
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,10 +8,27 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
|
|
12
12
|
export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
|
|
15
|
+
function _extends() {
|
|
16
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
+
var source = arguments[i];
|
|
19
|
+
|
|
20
|
+
for (var key in source) {
|
|
21
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
22
|
+
target[key] = source[key];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
return _extends.apply(this, arguments);
|
|
30
|
+
}
|
|
31
|
+
|
|
15
32
|
/**
|
|
16
33
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
17
34
|
*
|
|
@@ -235,23 +252,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
235
252
|
RouteErrorContext.displayName = "RouteError";
|
|
236
253
|
}
|
|
237
254
|
|
|
238
|
-
function _extends() {
|
|
239
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
240
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
241
|
-
var source = arguments[i];
|
|
242
|
-
|
|
243
|
-
for (var key in source) {
|
|
244
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
245
|
-
target[key] = source[key];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return target;
|
|
251
|
-
};
|
|
252
|
-
return _extends.apply(this, arguments);
|
|
253
|
-
}
|
|
254
|
-
|
|
255
255
|
/**
|
|
256
256
|
* Returns the full href for the given "to" value. This is useful for building
|
|
257
257
|
* custom links that are also accessible and preserve right-click behavior.
|
|
@@ -263,9 +263,9 @@ function useHref(to, _temp) {
|
|
|
263
263
|
let {
|
|
264
264
|
relative
|
|
265
265
|
} = _temp === void 0 ? {} : _temp;
|
|
266
|
-
!useInRouterContext() ? process.env.NODE_ENV !== "production" ?
|
|
266
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
267
267
|
// router loaded. We can help them understand how to avoid that.
|
|
268
|
-
"useHref() may be used only in the context of a <Router> component.") :
|
|
268
|
+
"useHref() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
269
269
|
let {
|
|
270
270
|
basename,
|
|
271
271
|
navigator
|
|
@@ -313,9 +313,9 @@ function useInRouterContext() {
|
|
|
313
313
|
*/
|
|
314
314
|
|
|
315
315
|
function useLocation() {
|
|
316
|
-
!useInRouterContext() ? process.env.NODE_ENV !== "production" ?
|
|
316
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
317
317
|
// router loaded. We can help them understand how to avoid that.
|
|
318
|
-
"useLocation() may be used only in the context of a <Router> component.") :
|
|
318
|
+
"useLocation() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
319
319
|
return React.useContext(LocationContext).location;
|
|
320
320
|
}
|
|
321
321
|
/**
|
|
@@ -337,9 +337,9 @@ function useNavigationType() {
|
|
|
337
337
|
*/
|
|
338
338
|
|
|
339
339
|
function useMatch(pattern) {
|
|
340
|
-
!useInRouterContext() ? process.env.NODE_ENV !== "production" ?
|
|
340
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
341
341
|
// router loaded. We can help them understand how to avoid that.
|
|
342
|
-
"useMatch() may be used only in the context of a <Router> component.") :
|
|
342
|
+
"useMatch() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
343
343
|
let {
|
|
344
344
|
pathname
|
|
345
345
|
} = useLocation();
|
|
@@ -356,9 +356,9 @@ function useMatch(pattern) {
|
|
|
356
356
|
* @see https://reactrouter.com/hooks/use-navigate
|
|
357
357
|
*/
|
|
358
358
|
function useNavigate() {
|
|
359
|
-
!useInRouterContext() ? process.env.NODE_ENV !== "production" ?
|
|
359
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
360
360
|
// router loaded. We can help them understand how to avoid that.
|
|
361
|
-
"useNavigate() may be used only in the context of a <Router> component.") :
|
|
361
|
+
"useNavigate() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
362
362
|
let {
|
|
363
363
|
basename,
|
|
364
364
|
navigator
|
|
@@ -471,9 +471,9 @@ function useResolvedPath(to, _temp2) {
|
|
|
471
471
|
*/
|
|
472
472
|
|
|
473
473
|
function useRoutes(routes, locationArg) {
|
|
474
|
-
!useInRouterContext() ? process.env.NODE_ENV !== "production" ?
|
|
474
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
475
475
|
// router loaded. We can help them understand how to avoid that.
|
|
476
|
-
"useRoutes() may be used only in the context of a <Router> component.") :
|
|
476
|
+
"useRoutes() may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
477
477
|
let {
|
|
478
478
|
navigator
|
|
479
479
|
} = React.useContext(NavigationContext);
|
|
@@ -519,7 +519,7 @@ function useRoutes(routes, locationArg) {
|
|
|
519
519
|
var _parsedLocationArg$pa;
|
|
520
520
|
|
|
521
521
|
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
522
|
-
!(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ?
|
|
522
|
+
!(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, " + "the location pathname must begin with the portion of the URL pathname that was " + ("matched by all parent routes. The current pathname base is \"" + parentPathnameBase + "\" ") + ("but pathname \"" + parsedLocationArg.pathname + "\" was given in the `location` prop.")) : UNSAFE_invariant(false) : void 0;
|
|
523
523
|
location = parsedLocationArg;
|
|
524
524
|
} else {
|
|
525
525
|
location = locationFromContext;
|
|
@@ -692,7 +692,7 @@ function _renderMatches(matches, parentMatches, dataRouterState) {
|
|
|
692
692
|
|
|
693
693
|
if (errors != null) {
|
|
694
694
|
let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
|
|
695
|
-
!(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ?
|
|
695
|
+
!(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "Could not find a matching route for the current errors: " + errors) : UNSAFE_invariant(false) : void 0;
|
|
696
696
|
renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
|
|
697
697
|
}
|
|
698
698
|
|
|
@@ -750,26 +750,26 @@ function getDataRouterConsoleError(hookName) {
|
|
|
750
750
|
|
|
751
751
|
function useDataRouterContext(hookName) {
|
|
752
752
|
let ctx = React.useContext(DataRouterContext);
|
|
753
|
-
!ctx ? process.env.NODE_ENV !== "production" ?
|
|
753
|
+
!ctx ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0;
|
|
754
754
|
return ctx;
|
|
755
755
|
}
|
|
756
756
|
|
|
757
757
|
function useDataRouterState(hookName) {
|
|
758
758
|
let state = React.useContext(DataRouterStateContext);
|
|
759
|
-
!state ? process.env.NODE_ENV !== "production" ?
|
|
759
|
+
!state ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0;
|
|
760
760
|
return state;
|
|
761
761
|
}
|
|
762
762
|
|
|
763
763
|
function useRouteContext(hookName) {
|
|
764
764
|
let route = React.useContext(RouteContext);
|
|
765
|
-
!route ? process.env.NODE_ENV !== "production" ?
|
|
765
|
+
!route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : UNSAFE_invariant(false) : void 0;
|
|
766
766
|
return route;
|
|
767
767
|
}
|
|
768
768
|
|
|
769
769
|
function useCurrentRouteId(hookName) {
|
|
770
770
|
let route = useRouteContext(hookName);
|
|
771
771
|
let thisRoute = route.matches[route.matches.length - 1];
|
|
772
|
-
!thisRoute.route.id ? process.env.NODE_ENV !== "production" ?
|
|
772
|
+
!thisRoute.route.id ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, hookName + " can only be used on routes that contain a unique \"id\"") : UNSAFE_invariant(false) : void 0;
|
|
773
773
|
return thisRoute.route.id;
|
|
774
774
|
}
|
|
775
775
|
/**
|
|
@@ -852,7 +852,7 @@ function useRouteLoaderData(routeId) {
|
|
|
852
852
|
function useActionData() {
|
|
853
853
|
let state = useDataRouterState(DataRouterStateHook.UseActionData);
|
|
854
854
|
let route = React.useContext(RouteContext);
|
|
855
|
-
!route ? process.env.NODE_ENV !== "production" ?
|
|
855
|
+
!route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useActionData must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0;
|
|
856
856
|
return Object.values((state == null ? void 0 : state.actionData) || {})[0];
|
|
857
857
|
}
|
|
858
858
|
/**
|
|
@@ -1029,9 +1029,9 @@ function Navigate(_ref3) {
|
|
|
1029
1029
|
state,
|
|
1030
1030
|
relative
|
|
1031
1031
|
} = _ref3;
|
|
1032
|
-
!useInRouterContext() ? process.env.NODE_ENV !== "production" ?
|
|
1032
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of
|
|
1033
1033
|
// the router loaded. We can help them understand how to avoid that.
|
|
1034
|
-
"<Navigate> may be used only in the context of a <Router> component.") :
|
|
1034
|
+
"<Navigate> may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
1035
1035
|
process.env.NODE_ENV !== "production" ? warning(!React.useContext(NavigationContext).static, "<Navigate> must not be used on the initial render in a <StaticRouter>. " + "This is a no-op, but you should modify your code so the <Navigate> is " + "only ever rendered in response to some user interaction or state change.") : void 0;
|
|
1036
1036
|
let dataRouterState = React.useContext(DataRouterStateContext);
|
|
1037
1037
|
let navigate = useNavigate();
|
|
@@ -1067,7 +1067,7 @@ function Outlet(props) {
|
|
|
1067
1067
|
* @see https://reactrouter.com/components/route
|
|
1068
1068
|
*/
|
|
1069
1069
|
function Route(_props) {
|
|
1070
|
-
process.env.NODE_ENV !== "production" ?
|
|
1070
|
+
process.env.NODE_ENV !== "production" ? 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>.") : UNSAFE_invariant(false) ;
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
1073
|
/**
|
|
@@ -1088,9 +1088,15 @@ function Router(_ref4) {
|
|
|
1088
1088
|
navigator,
|
|
1089
1089
|
static: staticProp = false
|
|
1090
1090
|
} = _ref4;
|
|
1091
|
-
|
|
1091
|
+
// Temporarily commented out for testing of <CompatRouter> nested in a
|
|
1092
|
+
// <RouterProvider>
|
|
1093
|
+
// invariant(
|
|
1094
|
+
// !useInRouterContext(),
|
|
1095
|
+
// `You cannot render a <Router> inside another <Router>.` +
|
|
1096
|
+
// ` You should never have more than one in your app.`
|
|
1097
|
+
// );
|
|
1098
|
+
// Preserve trailing slashes on basename, so we can let the user control
|
|
1092
1099
|
// the enforcement of trailing slashes throughout the app
|
|
1093
|
-
|
|
1094
1100
|
let basename = basenameProp.replace(/^\/*/, "/");
|
|
1095
1101
|
let navigationContext = React.useMemo(() => ({
|
|
1096
1102
|
basename,
|
|
@@ -1327,8 +1333,8 @@ function createRoutesFromChildren(children, parentPath) {
|
|
|
1327
1333
|
return;
|
|
1328
1334
|
}
|
|
1329
1335
|
|
|
1330
|
-
!(element.type === Route) ? process.env.NODE_ENV !== "production" ?
|
|
1331
|
-
!(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ?
|
|
1336
|
+
!(element.type === Route) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : UNSAFE_invariant(false) : void 0;
|
|
1337
|
+
!(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "An index route cannot have child routes.") : UNSAFE_invariant(false) : void 0;
|
|
1332
1338
|
let treePath = [...parentPath, index];
|
|
1333
1339
|
let route = {
|
|
1334
1340
|
id: element.props.id || treePath.join("-"),
|
|
@@ -1341,8 +1347,7 @@ function createRoutesFromChildren(children, parentPath) {
|
|
|
1341
1347
|
errorElement: element.props.errorElement,
|
|
1342
1348
|
hasErrorBoundary: element.props.errorElement != null,
|
|
1343
1349
|
shouldRevalidate: element.props.shouldRevalidate,
|
|
1344
|
-
handle: element.props.handle
|
|
1345
|
-
lazy: element.props.lazy
|
|
1350
|
+
handle: element.props.handle
|
|
1346
1351
|
};
|
|
1347
1352
|
|
|
1348
1353
|
if (element.props.children) {
|
|
@@ -1360,6 +1365,27 @@ function createRoutesFromChildren(children, parentPath) {
|
|
|
1360
1365
|
function renderMatches(matches) {
|
|
1361
1366
|
return _renderMatches(matches);
|
|
1362
1367
|
}
|
|
1368
|
+
/**
|
|
1369
|
+
* @private
|
|
1370
|
+
* Walk the route tree and add hasErrorBoundary if it's not provided, so that
|
|
1371
|
+
* users providing manual route arrays can just specify errorElement
|
|
1372
|
+
*/
|
|
1373
|
+
|
|
1374
|
+
function enhanceManualRouteObjects(routes) {
|
|
1375
|
+
return routes.map(route => {
|
|
1376
|
+
let routeClone = _extends({}, route);
|
|
1377
|
+
|
|
1378
|
+
if (routeClone.hasErrorBoundary == null) {
|
|
1379
|
+
routeClone.hasErrorBoundary = routeClone.errorElement != null;
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
if (routeClone.children) {
|
|
1383
|
+
routeClone.children = enhanceManualRouteObjects(routeClone.children);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
return routeClone;
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1363
1389
|
|
|
1364
1390
|
function createMemoryRouter(routes, opts) {
|
|
1365
1391
|
return createRouter({
|
|
@@ -1369,11 +1395,9 @@ function createMemoryRouter(routes, opts) {
|
|
|
1369
1395
|
initialIndex: opts == null ? void 0 : opts.initialIndex
|
|
1370
1396
|
}),
|
|
1371
1397
|
hydrationData: opts == null ? void 0 : opts.hydrationData,
|
|
1372
|
-
routes
|
|
1373
|
-
hasErrorBoundary: route => Boolean(route.errorElement),
|
|
1374
|
-
onInitialize: opts == null ? void 0 : opts.onInitialize
|
|
1398
|
+
routes: enhanceManualRouteObjects(routes)
|
|
1375
1399
|
}).initialize();
|
|
1376
1400
|
} ///////////////////////////////////////////////////////////////////////////////
|
|
1377
1401
|
|
|
1378
|
-
export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
|
|
1402
|
+
export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
|
|
1379
1403
|
//# sourceMappingURL=index.js.map
|