@remix-run/router 0.0.0-experimental-b24023f3 → 0.0.0-experimental-c93c722c

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-b24023f3
2
+ * @remix-run/router v0.0.0-experimental-c93c722c
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
  });
@@ -2441,7 +2441,9 @@ function createRouter(init) {
2441
2441
  // state. If not, we need to switch to our loading state and load data,
2442
2442
  // preserving any new action data or existing action data (in the case of
2443
2443
  // a revalidation interrupting an actionReload)
2444
- if (!isUninterruptedRevalidation) {
2444
+ // If we have partialHydration enabled, then don't update the state for the
2445
+ // initial data load since iot's not a "navigation"
2446
+ if (!isUninterruptedRevalidation && (!future.v7_partialHydration || !initialHydration)) {
2445
2447
  revalidatingFetchers.forEach(rf => {
2446
2448
  let fetcher = state.fetchers.get(rf.key);
2447
2449
  let revalidatingFetcher = getLoadingFetcher(undefined, fetcher ? fetcher.data : undefined);
@@ -3837,8 +3839,8 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
3837
3839
  let navigationMatches = boundaryMatches.filter((match, index) => {
3838
3840
  if (isInitialLoad) {
3839
3841
  // 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;
3842
+ // call the unhydrated loaders
3843
+ return isUnhydratedRoute(state, match.route);
3842
3844
  }
3843
3845
  if (match.route.lazy) {
3844
3846
  // We haven't loaded this route yet so we don't know if it's got a loader!
@@ -3948,6 +3950,14 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
3948
3950
  });
3949
3951
  return [navigationMatches, revalidatingFetchers];
3950
3952
  }
3953
+
3954
+ // Is this route unhydrated (when v7_partialHydration=true) such that we need
3955
+ // to call it's loader on the initial router creation
3956
+ function isUnhydratedRoute(state, route) {
3957
+ return route.loader != null && state.loaderData[route.id] === undefined && (!state.errors ||
3958
+ // Loader ran but errored - don't re-run
3959
+ state.errors[route.id] === undefined);
3960
+ }
3951
3961
  function isNewLoader(currentLoaderData, currentMatch, match) {
3952
3962
  let isNew =
3953
3963
  // [a] -> [a, b]