react-router 6.25.1 → 6.26.0-pre.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,5 +1,20 @@
1
1
  # `react-router`
2
2
 
3
+ ## 6.26.0-pre.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add a new `replace(url, init?)` alternative to `redirect(url, init?)` that performs a `history.replaceState` instead of a `history.pushState` on client-side navigation redirects ([#11811](https://github.com/remix-run/react-router/pull/11811))
8
+
9
+ ### Patch Changes
10
+
11
+ - Fix initial hydration behavior when using `future.v7_partialHydration` along with `unstable_patchRoutesOnMiss` ([#11838](https://github.com/remix-run/react-router/pull/11838))
12
+
13
+ - During initial hydration, `router.state.matches` will now include any partial matches so that we can render ancestor `HydrateFallback` components
14
+
15
+ - Updated dependencies:
16
+ - `@remix-run/router@1.19.0-pre.0`
17
+
3
18
  ## 6.25.1
4
19
 
5
20
  No significant changes to this package were made in this release. [See the repo `CHANGELOG.md`](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md) for an overview of all changes in v6.25.1.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, unstable_DataStrategyFunction, unstable_DataStrategyFunctionArgs, unstable_DataStrategyMatch, ErrorResponse, Fetcher, HydrationState, InitialEntry, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, RedirectFunction, RelativeRoutingType, Router as RemixRouter, FutureConfig as RouterFutureConfig, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, unstable_HandlerResult, unstable_AgnosticPatchRoutesOnMissFunction } from "@remix-run/router";
2
- import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, resolvePath } from "@remix-run/router";
2
+ import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, replace, resolvePath } from "@remix-run/router";
3
3
  import type { AwaitProps, FutureConfig, IndexRouteProps, LayoutRouteProps, MemoryRouterProps, NavigateProps, OutletProps, PathRouteProps, RouteProps, RouterProps, RouterProviderProps, RoutesProps } from "./lib/components";
4
4
  import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, createRoutesFromChildren, renderMatches } from "./lib/components";
5
5
  import type { DataRouteMatch, DataRouteObject, IndexRouteObject, NavigateOptions, Navigator, NonIndexRouteObject, RouteMatch, RouteObject } from "./lib/context";
@@ -10,7 +10,7 @@ type Hash = string;
10
10
  type Pathname = string;
11
11
  type Search = string;
12
12
  export type { ActionFunction, ActionFunctionArgs, AwaitProps, DataRouteMatch, DataRouteObject, unstable_DataStrategyFunction, unstable_DataStrategyFunctionArgs, unstable_DataStrategyMatch, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, PathRouteProps, Pathname, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, Blocker, BlockerFunction, unstable_HandlerResult, };
13
- export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
13
+ export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, replace, renderMatches, resolvePath, useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
14
14
  declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
15
15
  hasErrorBoundary: boolean;
16
16
  };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.25.1
2
+ * React Router v6.26.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import * as React from 'react';
12
12
  import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_decodePath, UNSAFE_getResolveToMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, UNSAFE_convertRouteMatchToUiMatch, stripBasename, IDLE_BLOCKER, isRouteErrorResponse, createMemoryHistory, AbortedDeferredError, createRouter } from '@remix-run/router';
13
- export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, resolvePath } from '@remix-run/router';
13
+ export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, replace, resolvePath } from '@remix-run/router';
14
14
 
15
15
  function _extends() {
16
16
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -530,7 +530,7 @@ function RenderedRoute(_ref) {
530
530
  }, children);
531
531
  }
532
532
  function _renderMatches(matches, parentMatches, dataRouterState, future) {
533
- var _dataRouterState2;
533
+ var _dataRouterState;
534
534
  if (parentMatches === void 0) {
535
535
  parentMatches = [];
536
536
  }
@@ -541,11 +541,22 @@ function _renderMatches(matches, parentMatches, dataRouterState, future) {
541
541
  future = null;
542
542
  }
543
543
  if (matches == null) {
544
- var _dataRouterState;
545
- if ((_dataRouterState = dataRouterState) != null && _dataRouterState.errors) {
544
+ var _future;
545
+ if (!dataRouterState) {
546
+ return null;
547
+ }
548
+ if (dataRouterState.errors) {
546
549
  // Don't bail if we have data router errors so we can render them in the
547
550
  // boundary. Use the pre-matched (or shimmed) matches
548
551
  matches = dataRouterState.matches;
552
+ } else if ((_future = future) != null && _future.v7_partialHydration && parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
553
+ // Don't bail if we're initializing with partial hydration and we have
554
+ // router matches. That means we're actively running `patchRoutesOnMiss`
555
+ // so we should render down the partial matches to the appropriate
556
+ // `HydrateFallback`. We only do this if `parentMatches` is empty so it
557
+ // only impacts the root matches for `RouterProvider` and no descendant
558
+ // `<Routes>`
559
+ matches = dataRouterState.matches;
549
560
  } else {
550
561
  return null;
551
562
  }
@@ -553,7 +564,7 @@ function _renderMatches(matches, parentMatches, dataRouterState, future) {
553
564
  let renderedMatches = matches;
554
565
 
555
566
  // If we have data errors, trim matches to the highest error boundary
556
- let errors = (_dataRouterState2 = dataRouterState) == null ? void 0 : _dataRouterState2.errors;
567
+ let errors = (_dataRouterState = dataRouterState) == null ? void 0 : _dataRouterState.errors;
557
568
  if (errors != null) {
558
569
  let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== undefined);
559
570
  !(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : UNSAFE_invariant(false) : void 0;