react-router-dom 6.14.2 → 6.15.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,21 @@
1
1
  # `react-router-dom`
2
2
 
3
+ ## 6.15.0-pre.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add's a new `redirectDocument()` function which allows users to specify that a redirect from a `loader`/`action` should trigger a document reload (via `window.location`) instead of attempting to navigate to the redirected location via React Router ([#10705](https://github.com/remix-run/react-router/pull/10705))
8
+
9
+ ### Patch Changes
10
+
11
+ - Fixes an edge-case affecting web extensions in Firefox that use `URLSearchParams` and the `useSearchParams` hook. ([#10620](https://github.com/remix-run/react-router/pull/10620))
12
+ - Do not include hash in `useFormAction()` for unspecified actions since it cannot be determined on the server and causes hydration issues ([#10758](https://github.com/remix-run/react-router/pull/10758))
13
+ - [Remove] add back in `setTimeout` removal from `usePrompt` ([#10718](https://github.com/remix-run/react-router/pull/10718))
14
+ - Reorder effects in `unstable_usePrompt` to avoid throwing an exception if the prompt is unblocked and a navigation is performed syncronously ([#10687](https://github.com/remix-run/react-router/pull/10687))
15
+ - Updated dependencies:
16
+ - `@remix-run/router@1.8.0-pre.0`
17
+ - `react-router@6.15.0-pre.0`
18
+
3
19
  ## 6.14.2
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ import { createSearchParams } from "./dom";
10
10
  export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
11
11
  export { createSearchParams };
12
12
  export type { ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To, } from "react-router";
13
- export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
13
+ export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
14
14
  /** @internal */
15
15
  export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, } from "react-router";
16
16
  declare global {
@@ -33,7 +33,7 @@ export interface BrowserRouterProps {
33
33
  /**
34
34
  * A `<Router>` for use in web browsers. Provides the cleanest URLs.
35
35
  */
36
- export declare function BrowserRouter({ basename, children, future, window, }: BrowserRouterProps): JSX.Element;
36
+ export declare function BrowserRouter({ basename, children, future, window, }: BrowserRouterProps): React.JSX.Element;
37
37
  export interface HashRouterProps {
38
38
  basename?: string;
39
39
  children?: React.ReactNode;
@@ -44,7 +44,7 @@ export interface HashRouterProps {
44
44
  * A `<Router>` for use in web browsers. Stores the location in the hash
45
45
  * portion of the URL so it is not sent to the server.
46
46
  */
47
- export declare function HashRouter({ basename, children, future, window, }: HashRouterProps): JSX.Element;
47
+ export declare function HashRouter({ basename, children, future, window, }: HashRouterProps): React.JSX.Element;
48
48
  export interface HistoryRouterProps {
49
49
  basename?: string;
50
50
  children?: React.ReactNode;
@@ -57,7 +57,7 @@ export interface HistoryRouterProps {
57
57
  * two versions of the history library to your bundles unless you use the same
58
58
  * version of the history library that React Router uses internally.
59
59
  */
60
- declare function HistoryRouter({ basename, children, future, history, }: HistoryRouterProps): JSX.Element;
60
+ declare function HistoryRouter({ basename, children, future, history, }: HistoryRouterProps): React.JSX.Element;
61
61
  declare namespace HistoryRouter {
62
62
  var displayName: string;
63
63
  }
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v6.14.2
2
+ * React Router DOM v6.15.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_mapRouteProperties, Router, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router';
13
- export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router';
13
+ export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router';
14
14
  import { stripBasename, UNSAFE_warning, createRouter, createBrowserHistory, createHashHistory, ErrorResponse, UNSAFE_invariant, joinPaths } from '@remix-run/router';
15
15
 
16
16
  function _extends() {
@@ -98,13 +98,18 @@ function createSearchParams(init) {
98
98
  function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
99
99
  let searchParams = createSearchParams(locationSearch);
100
100
  if (defaultSearchParams) {
101
- for (let key of defaultSearchParams.keys()) {
101
+ // Use `defaultSearchParams.forEach(...)` here instead of iterating of
102
+ // `defaultSearchParams.keys()` to work-around a bug in Firefox related to
103
+ // web extensions. Relevant Bugzilla tickets:
104
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1414602
105
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1023984
106
+ defaultSearchParams.forEach((_, key) => {
102
107
  if (!searchParams.has(key)) {
103
108
  defaultSearchParams.getAll(key).forEach(value => {
104
109
  searchParams.append(key, value);
105
110
  });
106
111
  }
107
- }
112
+ });
108
113
  }
109
114
  return searchParams;
110
115
  }
@@ -808,17 +813,15 @@ function useFormAction(action, _temp2) {
808
813
  relative
809
814
  }));
810
815
  // Previously we set the default action to ".". The problem with this is that
811
- // `useResolvedPath(".")` excludes search params and the hash of the resolved
812
- // URL. This is the intended behavior of when "." is specifically provided as
816
+ // `useResolvedPath(".")` excludes search params of the resolved URL. This is
817
+ // the intended behavior of when "." is specifically provided as
813
818
  // the form action, but inconsistent w/ browsers when the action is omitted.
814
819
  // https://github.com/remix-run/remix/issues/927
815
820
  let location = useLocation();
816
821
  if (action == null) {
817
- // Safe to write to these directly here since if action was undefined, we
822
+ // Safe to write to this directly here since if action was undefined, we
818
823
  // would have called useResolvedPath(".") which will never include a search
819
- // or hash
820
824
  path.search = location.search;
821
- path.hash = location.hash;
822
825
  // When grabbing search params from the URL, remove the automatically
823
826
  // inserted ?index param so we match the useResolvedPath search behavior
824
827
  // which would not include ?index
@@ -1055,21 +1058,24 @@ function usePrompt(_ref8) {
1055
1058
  message
1056
1059
  } = _ref8;
1057
1060
  let blocker = unstable_useBlocker(when);
1058
- React.useEffect(() => {
1059
- if (blocker.state === "blocked" && !when) {
1060
- blocker.reset();
1061
- }
1062
- }, [blocker, when]);
1063
1061
  React.useEffect(() => {
1064
1062
  if (blocker.state === "blocked") {
1065
1063
  let proceed = window.confirm(message);
1066
1064
  if (proceed) {
1065
+ // This timeout is needed to avoid a weird "race" on POP navigations
1066
+ // between the `window.history` revert navigation and the result of
1067
+ // `window.confirm`
1067
1068
  setTimeout(blocker.proceed, 0);
1068
1069
  } else {
1069
1070
  blocker.reset();
1070
1071
  }
1071
1072
  }
1072
1073
  }, [blocker, message]);
1074
+ React.useEffect(() => {
1075
+ if (blocker.state === "blocked" && !when) {
1076
+ blocker.reset();
1077
+ }
1078
+ }, [blocker, when]);
1073
1079
  }
1074
1080
  //#endregion
1075
1081