react-router 0.0.0-experimental-cf9637ce → 0.0.0-experimental-e7e9ce6e

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-cf9637ce
2
+ * React Router v0.0.0-experimental-e7e9ce6e
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -285,7 +285,7 @@
285
285
  let {
286
286
  relative
287
287
  } = _temp === void 0 ? {} : _temp;
288
- !useInRouterContext() ? router.invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
288
+ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
289
289
  // router loaded. We can help them understand how to avoid that.
290
290
  "useHref() may be used only in the context of a <Router> component.") : void 0;
291
291
  let {
@@ -335,7 +335,7 @@
335
335
  */
336
336
 
337
337
  function useLocation() {
338
- !useInRouterContext() ? router.invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
338
+ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
339
339
  // router loaded. We can help them understand how to avoid that.
340
340
  "useLocation() may be used only in the context of a <Router> component.") : void 0;
341
341
  return React__namespace.useContext(LocationContext).location;
@@ -359,7 +359,7 @@
359
359
  */
360
360
 
361
361
  function useMatch(pattern) {
362
- !useInRouterContext() ? router.invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
362
+ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
363
363
  // router loaded. We can help them understand how to avoid that.
364
364
  "useMatch() may be used only in the context of a <Router> component.") : void 0;
365
365
  let {
@@ -378,7 +378,7 @@
378
378
  * @see https://reactrouter.com/hooks/use-navigate
379
379
  */
380
380
  function useNavigate() {
381
- !useInRouterContext() ? router.invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
381
+ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
382
382
  // router loaded. We can help them understand how to avoid that.
383
383
  "useNavigate() may be used only in the context of a <Router> component.") : void 0;
384
384
  let {
@@ -493,7 +493,7 @@
493
493
  */
494
494
 
495
495
  function useRoutes(routes, locationArg) {
496
- !useInRouterContext() ? router.invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
496
+ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
497
497
  // router loaded. We can help them understand how to avoid that.
498
498
  "useRoutes() may be used only in the context of a <Router> component.") : void 0;
499
499
  let {
@@ -541,7 +541,7 @@
541
541
  var _parsedLocationArg$pa;
542
542
 
543
543
  let parsedLocationArg = typeof locationArg === "string" ? router.parsePath(locationArg) : locationArg;
544
- !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? router.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.")) : void 0;
544
+ !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? router.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.")) : void 0;
545
545
  location = parsedLocationArg;
546
546
  } else {
547
547
  location = locationFromContext;
@@ -714,7 +714,7 @@
714
714
 
715
715
  if (errors != null) {
716
716
  let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]));
717
- !(errorIndex >= 0) ? router.invariant(false, "Could not find a matching route for the current errors: " + errors) : void 0;
717
+ !(errorIndex >= 0) ? router.UNSAFE_invariant(false, "Could not find a matching route for the current errors: " + errors) : void 0;
718
718
  renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
719
719
  }
720
720
 
@@ -772,26 +772,26 @@
772
772
 
773
773
  function useDataRouterContext(hookName) {
774
774
  let ctx = React__namespace.useContext(DataRouterContext);
775
- !ctx ? router.invariant(false, getDataRouterConsoleError(hookName)) : void 0;
775
+ !ctx ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
776
776
  return ctx;
777
777
  }
778
778
 
779
779
  function useDataRouterState(hookName) {
780
780
  let state = React__namespace.useContext(DataRouterStateContext);
781
- !state ? router.invariant(false, getDataRouterConsoleError(hookName)) : void 0;
781
+ !state ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
782
782
  return state;
783
783
  }
784
784
 
785
785
  function useRouteContext(hookName) {
786
786
  let route = React__namespace.useContext(RouteContext);
787
- !route ? router.invariant(false, getDataRouterConsoleError(hookName)) : void 0;
787
+ !route ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
788
788
  return route;
789
789
  }
790
790
 
791
791
  function useCurrentRouteId(hookName) {
792
792
  let route = useRouteContext(hookName);
793
793
  let thisRoute = route.matches[route.matches.length - 1];
794
- !thisRoute.route.id ? router.invariant(false, hookName + " can only be used on routes that contain a unique \"id\"") : void 0;
794
+ !thisRoute.route.id ? router.UNSAFE_invariant(false, hookName + " can only be used on routes that contain a unique \"id\"") : void 0;
795
795
  return thisRoute.route.id;
796
796
  }
797
797
  /**
@@ -874,7 +874,7 @@
874
874
  function useActionData() {
875
875
  let state = useDataRouterState(DataRouterStateHook.UseActionData);
876
876
  let route = React__namespace.useContext(RouteContext);
877
- !route ? router.invariant(false, "useActionData must be used inside a RouteContext") : void 0;
877
+ !route ? router.UNSAFE_invariant(false, "useActionData must be used inside a RouteContext") : void 0;
878
878
  return Object.values((state == null ? void 0 : state.actionData) || {})[0];
879
879
  }
880
880
  /**
@@ -1051,7 +1051,7 @@
1051
1051
  state,
1052
1052
  relative
1053
1053
  } = _ref3;
1054
- !useInRouterContext() ? router.invariant(false, // TODO: This error is probably because they somehow have 2 versions of
1054
+ !useInRouterContext() ? router.UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of
1055
1055
  // the router loaded. We can help them understand how to avoid that.
1056
1056
  "<Navigate> may be used only in the context of a <Router> component.") : void 0;
1057
1057
  router.warning(!React__namespace.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.") ;
@@ -1089,7 +1089,7 @@
1089
1089
  * @see https://reactrouter.com/components/route
1090
1090
  */
1091
1091
  function Route(_props) {
1092
- router.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>.") ;
1092
+ 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>.") ;
1093
1093
  }
1094
1094
 
1095
1095
  /**
@@ -1110,9 +1110,15 @@
1110
1110
  navigator,
1111
1111
  static: staticProp = false
1112
1112
  } = _ref4;
1113
- !!useInRouterContext() ? router.invariant(false, "You cannot render a <Router> inside another <Router>." + " You should never have more than one in your app.") : void 0; // Preserve trailing slashes on basename, so we can let the user control
1113
+ // Temporarily commented out for testing of <CompatRouter> nested in a
1114
+ // <RouterProvider>
1115
+ // invariant(
1116
+ // !useInRouterContext(),
1117
+ // `You cannot render a <Router> inside another <Router>.` +
1118
+ // ` You should never have more than one in your app.`
1119
+ // );
1120
+ // Preserve trailing slashes on basename, so we can let the user control
1114
1121
  // the enforcement of trailing slashes throughout the app
1115
-
1116
1122
  let basename = basenameProp.replace(/^\/*/, "/");
1117
1123
  let navigationContext = React__namespace.useMemo(() => ({
1118
1124
  basename,
@@ -1349,8 +1355,8 @@
1349
1355
  return;
1350
1356
  }
1351
1357
 
1352
- !(element.type === Route) ? router.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>") : void 0;
1353
- !(!element.props.index || !element.props.children) ? router.invariant(false, "An index route cannot have child routes.") : void 0;
1358
+ !(element.type === Route) ? router.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>") : void 0;
1359
+ !(!element.props.index || !element.props.children) ? router.UNSAFE_invariant(false, "An index route cannot have child routes.") : void 0;
1354
1360
  let treePath = [...parentPath, index];
1355
1361
  let route = {
1356
1362
  id: element.props.id || treePath.join("-"),