@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # `@remix-run/router`
2
2
 
3
- ## 1.14.0-pre.0
3
+ ## 1.14.0
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -45,9 +45,9 @@
45
45
 
46
46
  **Note:** When `future.v7_partialHydration` is provided, the `<RouterProvider fallbackElement>` prop is ignored since you can move it to a `Fallback` on your top-most route. The `fallbackElement` prop will be removed in React Router v7 when `v7_partialHydration` behavior becomes the standard behavior.
47
47
 
48
- - Add a new `future.v7_relativeSplatPath` flag to implenent a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
48
+ - Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
49
49
 
50
- This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/issues/110788) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
50
+ This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
51
51
 
52
52
  **The Bug**
53
53
  The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
@@ -91,7 +91,7 @@
91
91
 
92
92
  **The Problem**
93
93
 
94
- The problem is that this concept of ignoring part of a pth breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
94
+ The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
95
95
 
96
96
  ```jsx
97
97
  // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
@@ -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
  *
@@ -1731,18 +1731,28 @@ function createRouter(init) {
1731
1731
  [route.id]: error
1732
1732
  };
1733
1733
  }
1734
-
1735
- // "Initialized" here really means "Can `RouterProvider` render my route tree?"
1736
- // Prior to `route.HydrateFallback`, we only had a root `fallbackElement` so we used
1737
- // `state.initialized` to render that instead of `<DataRoutes>`. Now that we
1738
- // support route level fallbacks we can always render and we'll just render
1739
- // as deep as we have data for and detect the nearest ancestor HydrateFallback
1740
- let initialized = future.v7_partialHydration ||
1741
- // All initialMatches need to be loaded before we're ready. If we have lazy
1742
- // functions around still then we'll need to run them in initialize()
1743
- !initialMatches.some(m => m.route.lazy) && (
1744
- // And we have to either have no loaders or have been provided hydrationData
1745
- !initialMatches.some(m => m.route.loader) || init.hydrationData != null);
1734
+ let initialized;
1735
+ let hasLazyRoutes = initialMatches.some(m => m.route.lazy);
1736
+ let hasLoaders = initialMatches.some(m => m.route.loader);
1737
+ if (hasLazyRoutes) {
1738
+ // All initialMatches need to be loaded before we're ready. If we have lazy
1739
+ // functions around still then we'll need to run them in initialize()
1740
+ initialized = false;
1741
+ } else if (!hasLoaders) {
1742
+ // If we've got no loaders to run, then we're good to go
1743
+ initialized = true;
1744
+ } else if (future.v7_partialHydration) {
1745
+ // If partial hydration is enabled, we're initialized so long as we were
1746
+ // provided with hydrationData for every route with a loader, and no loaders
1747
+ // were marked for explicit hydration
1748
+ let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1749
+ let errors = init.hydrationData ? init.hydrationData.errors : null;
1750
+ initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
1751
+ } else {
1752
+ // Without partial hydration - we're initialized if we were provided any
1753
+ // hydrationData - which is expected to be complete
1754
+ initialized = init.hydrationData != null;
1755
+ }
1746
1756
  let router;
1747
1757
  let state = {
1748
1758
  historyAction: init.history.action,
@@ -1909,7 +1919,7 @@ function createRouter(init) {
1909
1919
  // in the normal navigation flow. For SSR it's expected that lazy modules are
1910
1920
  // resolved prior to router creation since we can't go into a fallbackElement
1911
1921
  // UI for SSR'd apps
1912
- if (!state.initialized || future.v7_partialHydration && state.matches.some(m => isUnhydratedRoute(state, m.route))) {
1922
+ if (!state.initialized) {
1913
1923
  startNavigation(Action.Pop, state.location, {
1914
1924
  initialHydration: true
1915
1925
  });