@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.15.2
2
+ * @remix-run/router v1.15.3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1729,7 +1729,22 @@
1729
1729
  // were marked for explicit hydration
1730
1730
  let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1731
1731
  let errors = init.hydrationData ? init.hydrationData.errors : null;
1732
- initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
1732
+ let isRouteInitialized = m => {
1733
+ // No loader, nothing to initialize
1734
+ if (!m.route.loader) return true;
1735
+ // Explicitly opting-in to running on hydration
1736
+ if (m.route.loader.hydrate === true) return false;
1737
+ // Otherwise, initialized if hydrated with data or an error
1738
+ return loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined;
1739
+ };
1740
+
1741
+ // If errors exist, don't consider routes below the boundary
1742
+ if (errors) {
1743
+ let idx = initialMatches.findIndex(m => errors[m.route.id] !== undefined);
1744
+ initialized = initialMatches.slice(0, idx + 1).every(isRouteInitialized);
1745
+ } else {
1746
+ initialized = initialMatches.every(isRouteInitialized);
1747
+ }
1733
1748
  } else {
1734
1749
  // Without partial hydration - we're initialized if we were provided any
1735
1750
  // hydrationData - which is expected to be complete