@remix-run/router 1.14.0-pre.0 → 1.14.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 +4 -4
- package/dist/router.cjs.js +24 -14
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +24 -13
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +24 -14
- 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 +27 -16
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -817,19 +817,34 @@ export function createRouter(init: RouterInit): Router {
|
|
|
817
817
|
initialErrors = { [route.id]: error };
|
|
818
818
|
}
|
|
819
819
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
// as deep as we have data for and detect the nearest ancestor HydrateFallback
|
|
825
|
-
let initialized =
|
|
826
|
-
future.v7_partialHydration ||
|
|
820
|
+
let initialized: boolean;
|
|
821
|
+
let hasLazyRoutes = initialMatches.some((m) => m.route.lazy);
|
|
822
|
+
let hasLoaders = initialMatches.some((m) => m.route.loader);
|
|
823
|
+
if (hasLazyRoutes) {
|
|
827
824
|
// All initialMatches need to be loaded before we're ready. If we have lazy
|
|
828
825
|
// functions around still then we'll need to run them in initialize()
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
826
|
+
initialized = false;
|
|
827
|
+
} else if (!hasLoaders) {
|
|
828
|
+
// If we've got no loaders to run, then we're good to go
|
|
829
|
+
initialized = true;
|
|
830
|
+
} else if (future.v7_partialHydration) {
|
|
831
|
+
// If partial hydration is enabled, we're initialized so long as we were
|
|
832
|
+
// provided with hydrationData for every route with a loader, and no loaders
|
|
833
|
+
// were marked for explicit hydration
|
|
834
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
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
|
+
);
|
|
843
|
+
} else {
|
|
844
|
+
// Without partial hydration - we're initialized if we were provided any
|
|
845
|
+
// hydrationData - which is expected to be complete
|
|
846
|
+
initialized = init.hydrationData != null;
|
|
847
|
+
}
|
|
833
848
|
|
|
834
849
|
let router: Router;
|
|
835
850
|
let state: RouterState = {
|
|
@@ -1010,11 +1025,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1010
1025
|
// in the normal navigation flow. For SSR it's expected that lazy modules are
|
|
1011
1026
|
// resolved prior to router creation since we can't go into a fallbackElement
|
|
1012
1027
|
// UI for SSR'd apps
|
|
1013
|
-
if (
|
|
1014
|
-
!state.initialized ||
|
|
1015
|
-
(future.v7_partialHydration &&
|
|
1016
|
-
state.matches.some((m) => isUnhydratedRoute(state, m.route)))
|
|
1017
|
-
) {
|
|
1028
|
+
if (!state.initialized) {
|
|
1018
1029
|
startNavigation(HistoryAction.Pop, state.location, {
|
|
1019
1030
|
initialHydration: true,
|
|
1020
1031
|
});
|