react-router 0.0.0-experimental-e960cf1a → 0.0.0-experimental-bc2c864b

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-e960cf1a
2
+ * React Router v0.0.0-experimental-bc2c864b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -400,7 +400,7 @@
400
400
  });
401
401
  {
402
402
  router.UNSAFE_warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") ;
403
- router.UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined, "Matched leaf route at location \"" + location.pathname + location.search + location.hash + "\" " + "does not have an element or Component. This means it will render an <Outlet /> with a " + "null value by default resulting in an \"empty\" page.") ;
403
+ router.UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined || matches[matches.length - 1].route.lazy !== undefined, "Matched leaf route at location \"" + location.pathname + location.search + location.hash + "\" " + "does not have an element or Component. This means it will render an <Outlet /> with a " + "null value by default resulting in an \"empty\" page.") ;
404
404
  }
405
405
  let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
406
406
  params: Object.assign({}, parentParams, match.params),
@@ -574,17 +574,24 @@
574
574
  if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
575
575
  fallbackIndex = i;
576
576
  }
577
- if (match.route.loader && match.route.id && dataRouterState.loaderData[match.route.id] === undefined && (!dataRouterState.errors || dataRouterState.errors[match.route.id] === undefined)) {
578
- // We found the first route without data/errors which means it's loader
579
- // still needs to run. Flag that we need to render a fallback and
580
- // render up until the appropriate fallback
581
- renderFallback = true;
582
- if (fallbackIndex >= 0) {
583
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
584
- } else {
585
- renderedMatches = [renderedMatches[0]];
577
+ if (match.route.id) {
578
+ let {
579
+ loaderData,
580
+ errors
581
+ } = dataRouterState;
582
+ let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!errors || errors[match.route.id] === undefined);
583
+ if (match.route.lazy || needsToRunLoader) {
584
+ // We found the first route that's not ready to render (waiting on
585
+ // lazy, or has a loader that hasn't run yet). Flag that we need to
586
+ // render a fallback and render up until the appropriate fallback
587
+ renderFallback = true;
588
+ if (fallbackIndex >= 0) {
589
+ renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
590
+ } else {
591
+ renderedMatches = [renderedMatches[0]];
592
+ }
593
+ break;
586
594
  }
587
- break;
588
595
  }
589
596
  }
590
597
  }
@@ -962,7 +969,7 @@
962
969
  // pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
963
970
  React__namespace.useLayoutEffect(() => router$1.subscribe(setState), [router$1, setState]);
964
971
  React__namespace.useEffect(() => {
965
- router.UNSAFE_warning(fallbackElement == null || !router$1.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`") ;
972
+ router.UNSAFE_warning(fallbackElement == null || !router$1.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") ;
966
973
  // Only log this once on initial mount
967
974
  // eslint-disable-next-line react-hooks/exhaustive-deps
968
975
  }, []);
@@ -987,10 +994,7 @@
987
994
  router: router$1,
988
995
  navigator,
989
996
  static: false,
990
- basename,
991
- future: {
992
- v7_relativeSplatPath: router$1.future.v7_relativeSplatPath
993
- }
997
+ basename
994
998
  }), [router$1, navigator, basename]);
995
999
 
996
1000
  // The fragment and {null} here are important! We need them to keep React 18's
@@ -1007,8 +1011,11 @@
1007
1011
  basename: basename,
1008
1012
  location: state.location,
1009
1013
  navigationType: state.historyAction,
1010
- navigator: navigator
1011
- }, state.initialized ? /*#__PURE__*/React__namespace.createElement(DataRoutes, {
1014
+ navigator: navigator,
1015
+ future: {
1016
+ v7_relativeSplatPath: router$1.future.v7_relativeSplatPath
1017
+ }
1018
+ }, state.initialized || router$1.future.v7_partialHydration ? /*#__PURE__*/React__namespace.createElement(DataRoutes, {
1012
1019
  routes: router$1.routes,
1013
1020
  future: router$1.future,
1014
1021
  state: state