@remix-run/router 1.15.2 → 1.15.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
package/router.ts CHANGED
@@ -833,13 +833,27 @@ export function createRouter(init: RouterInit): Router {
833
833
  // were marked for explicit hydration
834
834
  let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
835
835
  let errors = init.hydrationData ? init.hydrationData.errors : null;
836
- initialized = initialMatches.every(
837
- (m) =>
838
- m.route.loader &&
839
- m.route.loader.hydrate !== true &&
840
- ((loaderData && loaderData[m.route.id] !== undefined) ||
841
- (errors && errors[m.route.id] !== undefined))
842
- );
836
+ let isRouteInitialized = (m: AgnosticDataRouteMatch) => {
837
+ // No loader, nothing to initialize
838
+ if (!m.route.loader) return true;
839
+ // Explicitly opting-in to running on hydration
840
+ if (m.route.loader.hydrate === true) return false;
841
+ // Otherwise, initialized if hydrated with data or an error
842
+ return (
843
+ (loaderData && loaderData[m.route.id] !== undefined) ||
844
+ (errors && errors[m.route.id] !== undefined)
845
+ );
846
+ };
847
+
848
+ // If errors exist, don't consider routes below the boundary
849
+ if (errors) {
850
+ let idx = initialMatches.findIndex(
851
+ (m) => errors![m.route.id] !== undefined
852
+ );
853
+ initialized = initialMatches.slice(0, idx + 1).every(isRouteInitialized);
854
+ } else {
855
+ initialized = initialMatches.every(isRouteInitialized);
856
+ }
843
857
  } else {
844
858
  // Without partial hydration - we're initialized if we were provided any
845
859
  // hydrationData - which is expected to be complete