@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.14.0-pre.0
2
+ * @remix-run/router v1.14.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1733,18 +1733,28 @@
1733
1733
  [route.id]: error
1734
1734
  };
1735
1735
  }
1736
-
1737
- // "Initialized" here really means "Can `RouterProvider` render my route tree?"
1738
- // Prior to `route.HydrateFallback`, we only had a root `fallbackElement` so we used
1739
- // `state.initialized` to render that instead of `<DataRoutes>`. Now that we
1740
- // support route level fallbacks we can always render and we'll just render
1741
- // as deep as we have data for and detect the nearest ancestor HydrateFallback
1742
- let initialized = future.v7_partialHydration ||
1743
- // All initialMatches need to be loaded before we're ready. If we have lazy
1744
- // functions around still then we'll need to run them in initialize()
1745
- !initialMatches.some(m => m.route.lazy) && (
1746
- // And we have to either have no loaders or have been provided hydrationData
1747
- !initialMatches.some(m => m.route.loader) || init.hydrationData != null);
1736
+ let initialized;
1737
+ let hasLazyRoutes = initialMatches.some(m => m.route.lazy);
1738
+ let hasLoaders = initialMatches.some(m => m.route.loader);
1739
+ if (hasLazyRoutes) {
1740
+ // All initialMatches need to be loaded before we're ready. If we have lazy
1741
+ // functions around still then we'll need to run them in initialize()
1742
+ initialized = false;
1743
+ } else if (!hasLoaders) {
1744
+ // If we've got no loaders to run, then we're good to go
1745
+ initialized = true;
1746
+ } else if (future.v7_partialHydration) {
1747
+ // If partial hydration is enabled, we're initialized so long as we were
1748
+ // provided with hydrationData for every route with a loader, and no loaders
1749
+ // were marked for explicit hydration
1750
+ let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1751
+ let errors = init.hydrationData ? init.hydrationData.errors : null;
1752
+ initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
1753
+ } else {
1754
+ // Without partial hydration - we're initialized if we were provided any
1755
+ // hydrationData - which is expected to be complete
1756
+ initialized = init.hydrationData != null;
1757
+ }
1748
1758
  let router;
1749
1759
  let state = {
1750
1760
  historyAction: init.history.action,
@@ -1911,7 +1921,7 @@
1911
1921
  // in the normal navigation flow. For SSR it's expected that lazy modules are
1912
1922
  // resolved prior to router creation since we can't go into a fallbackElement
1913
1923
  // UI for SSR'd apps
1914
- if (!state.initialized || future.v7_partialHydration && state.matches.some(m => isUnhydratedRoute(state, m.route))) {
1924
+ if (!state.initialized) {
1915
1925
  startNavigation(Action.Pop, state.location, {
1916
1926
  initialHydration: true
1917
1927
  });