@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/CHANGELOG.md +7 -0
- package/dist/router.cjs.js +17 -2
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +16 -2
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +17 -2
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/router.ts +21 -7
package/package.json
CHANGED
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
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
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
|