react-router 6.21.0 → 6.21.1-pre.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # `react-router`
2
2
 
3
+ ## 6.21.1-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
8
+ - Updated dependencies:
9
+ - `@remix-run/router@1.14.1-pre.0`
10
+
3
11
  ## 6.21.0
4
12
 
5
13
  ### Minor Changes
@@ -108,7 +116,7 @@
108
116
  <BrowserRouter>
109
117
  <Routes>
110
118
  <Route path="dashboard">
111
- <Route path="*" element={<Dashboard />} />
119
+ <Route index path="*" element={<Dashboard />} />
112
120
  </Route>
113
121
  </Routes>
114
122
  </BrowserRouter>
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.21.0
2
+ * React Router v6.21.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -378,7 +378,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
378
378
  });
379
379
  if (process.env.NODE_ENV !== "production") {
380
380
  process.env.NODE_ENV !== "production" ? UNSAFE_warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") : void 0;
381
- process.env.NODE_ENV !== "production" ? 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.") : void 0;
381
+ process.env.NODE_ENV !== "production" ? 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.") : void 0;
382
382
  }
383
383
  let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
384
384
  params: Object.assign({}, parentParams, match.params),
@@ -552,17 +552,24 @@ function _renderMatches(matches, parentMatches, dataRouterState, future) {
552
552
  if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
553
553
  fallbackIndex = i;
554
554
  }
555
- if (match.route.loader && match.route.id && dataRouterState.loaderData[match.route.id] === undefined && (!dataRouterState.errors || dataRouterState.errors[match.route.id] === undefined)) {
556
- // We found the first route without data/errors which means it's loader
557
- // still needs to run. Flag that we need to render a fallback and
558
- // render up until the appropriate fallback
559
- renderFallback = true;
560
- if (fallbackIndex >= 0) {
561
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
562
- } else {
563
- renderedMatches = [renderedMatches[0]];
555
+ if (match.route.id) {
556
+ let {
557
+ loaderData,
558
+ errors
559
+ } = dataRouterState;
560
+ let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!errors || errors[match.route.id] === undefined);
561
+ if (match.route.lazy || needsToRunLoader) {
562
+ // We found the first route that's not ready to render (waiting on
563
+ // lazy, or has a loader that hasn't run yet). Flag that we need to
564
+ // render a fallback and render up until the appropriate fallback
565
+ renderFallback = true;
566
+ if (fallbackIndex >= 0) {
567
+ renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
568
+ } else {
569
+ renderedMatches = [renderedMatches[0]];
570
+ }
571
+ break;
564
572
  }
565
- break;
566
573
  }
567
574
  }
568
575
  }