@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/dist/router.js CHANGED
@@ -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
  *
@@ -1380,17 +1380,28 @@ function createRouter(init) {
1380
1380
  [route.id]: error
1381
1381
  };
1382
1382
  }
1383
- // "Initialized" here really means "Can `RouterProvider` render my route tree?"
1384
- // Prior to `route.HydrateFallback`, we only had a root `fallbackElement` so we used
1385
- // `state.initialized` to render that instead of `<DataRoutes>`. Now that we
1386
- // support route level fallbacks we can always render and we'll just render
1387
- // as deep as we have data for and detect the nearest ancestor HydrateFallback
1388
- let initialized = future.v7_partialHydration ||
1389
- // All initialMatches need to be loaded before we're ready. If we have lazy
1390
- // functions around still then we'll need to run them in initialize()
1391
- !initialMatches.some(m => m.route.lazy) && (
1392
- // And we have to either have no loaders or have been provided hydrationData
1393
- !initialMatches.some(m => m.route.loader) || init.hydrationData != null);
1383
+ let initialized;
1384
+ let hasLazyRoutes = initialMatches.some(m => m.route.lazy);
1385
+ let hasLoaders = initialMatches.some(m => m.route.loader);
1386
+ if (hasLazyRoutes) {
1387
+ // All initialMatches need to be loaded before we're ready. If we have lazy
1388
+ // functions around still then we'll need to run them in initialize()
1389
+ initialized = false;
1390
+ } else if (!hasLoaders) {
1391
+ // If we've got no loaders to run, then we're good to go
1392
+ initialized = true;
1393
+ } else if (future.v7_partialHydration) {
1394
+ // If partial hydration is enabled, we're initialized so long as we were
1395
+ // provided with hydrationData for every route with a loader, and no loaders
1396
+ // were marked for explicit hydration
1397
+ let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1398
+ let errors = init.hydrationData ? init.hydrationData.errors : null;
1399
+ initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
1400
+ } else {
1401
+ // Without partial hydration - we're initialized if we were provided any
1402
+ // hydrationData - which is expected to be complete
1403
+ initialized = init.hydrationData != null;
1404
+ }
1394
1405
  let router;
1395
1406
  let state = {
1396
1407
  historyAction: init.history.action,
@@ -1533,7 +1544,7 @@ function createRouter(init) {
1533
1544
  // in the normal navigation flow. For SSR it's expected that lazy modules are
1534
1545
  // resolved prior to router creation since we can't go into a fallbackElement
1535
1546
  // UI for SSR'd apps
1536
- if (!state.initialized || future.v7_partialHydration && state.matches.some(m => isUnhydratedRoute(state, m.route))) {
1547
+ if (!state.initialized) {
1537
1548
  startNavigation(Action.Pop, state.location, {
1538
1549
  initialHydration: true
1539
1550
  });