@remix-run/router 0.0.0-experimental-178bc9ee → 0.0.0-experimental-4841e12b

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 v0.0.0-experimental-178bc9ee
2
+ * @remix-run/router v0.0.0-experimental-4841e12b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1901,7 +1901,7 @@ function createRouter(init) {
1901
1901
  // in the normal navigation flow. For SSR it's expected that lazy modules are
1902
1902
  // resolved prior to router creation since we can't go into a fallbackElement
1903
1903
  // UI for SSR'd apps
1904
- if (!state.initialized || future.v7_partialHydration && state.matches.some(m => m.route.loader && state.loaderData[m.route.id] === undefined)) {
1904
+ if (!state.initialized || future.v7_partialHydration && state.matches.some(m => isUnhydratedRoute(state, m.route))) {
1905
1905
  startNavigation(Action.Pop, state.location, {
1906
1906
  initialHydration: true
1907
1907
  });
@@ -3837,8 +3837,8 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
3837
3837
  let navigationMatches = boundaryMatches.filter((match, index) => {
3838
3838
  if (isInitialLoad) {
3839
3839
  // On initial hydration we don't do any shouldRevalidate stuff - we just
3840
- // call the loaders that don't have hydration data
3841
- return match.route.loader && state.loaderData[match.route.id] === undefined;
3840
+ // call the unhydrated loaders
3841
+ return isUnhydratedRoute(state, match.route);
3842
3842
  }
3843
3843
  if (match.route.lazy) {
3844
3844
  // We haven't loaded this route yet so we don't know if it's got a loader!
@@ -3948,6 +3948,14 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
3948
3948
  });
3949
3949
  return [navigationMatches, revalidatingFetchers];
3950
3950
  }
3951
+
3952
+ // Is this route unhydrated (when v7_partialHydration=true) such that we need
3953
+ // to call it's loader on the initial router creation
3954
+ function isUnhydratedRoute(state, route) {
3955
+ return route.loader != null && state.loaderData[route.id] === undefined && (!state.errors ||
3956
+ // Loader ran but errored - don't re-run
3957
+ state.errors[route.id] === undefined);
3958
+ }
3951
3959
  function isNewLoader(currentLoaderData, currentMatch, match) {
3952
3960
  let isNew =
3953
3961
  // [a] -> [a, b]