react-router-dom-v5-compat 6.14.2 → 6.15.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,17 @@
1
1
  # `react-router-dom-v5-compat`
2
2
 
3
+ ## 6.15.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
+ - Updated dependencies:
12
+ - `react-router-dom@6.15.0`
13
+ - `react-router@6.15.0`
14
+
3
15
  ## 6.14.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -47,6 +47,6 @@
47
47
  * deprecate the deep require if we wanted to avoid the duplication here.
48
48
  */
49
49
  export type { BrowserRouterProps, Hash, HashRouterProps, HistoryRouterProps, LinkProps, Location, Path, To, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigator, NavLinkProps, OutletProps, Params, ParamParseKey, PathMatch, RouteMatch, RouteObject, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, Pathname, Search, RoutesProps, ParamKeyValuePair, URLSearchParamsInit, ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, FetcherWithComponents, FormEncType, FormMethod, FormProps, GetScrollRestorationKeyFunction, IndexRouteObject, JsonFunction, LoaderFunction, LoaderFunctionArgs, Navigation, NonIndexRouteObject, PathPattern, RedirectFunction, RelativeRoutingType, RouterProviderProps, ScrollRestorationProps, ShouldRevalidateFunction, SubmitFunction, SubmitOptions, } from "./react-router-dom";
50
- export { BrowserRouter, HashRouter, Link, MemoryRouter, NavLink, Navigate, NavigationType, Outlet, Route, Router, Routes, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createPath, createRoutesFromChildren, createSearchParams, generatePath, matchPath, matchRoutes, parsePath, renderMatches, resolvePath, unstable_HistoryRouter, useHref, useInRouterContext, useLinkClickHandler, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams, AbortedDeferredError, Await, RouterProvider, ScrollRestoration, createBrowserRouter, createHashRouter, createMemoryRouter, createRoutesFromElements, defer, isRouteErrorResponse, Form, json, redirect, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, unstable_useBlocker, useFetcher, useFetchers, useFormAction, useLoaderData, useMatches, useNavigation, unstable_usePrompt, useRevalidator, useRouteError, useRouteLoaderData, useSubmit, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_useScrollRestoration, UNSAFE_useRouteId, } from "./react-router-dom";
50
+ export { BrowserRouter, HashRouter, Link, MemoryRouter, NavLink, Navigate, NavigationType, Outlet, Route, Router, Routes, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createPath, createRoutesFromChildren, createSearchParams, generatePath, matchPath, matchRoutes, parsePath, renderMatches, resolvePath, unstable_HistoryRouter, useHref, useInRouterContext, useLinkClickHandler, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams, AbortedDeferredError, Await, RouterProvider, ScrollRestoration, createBrowserRouter, createHashRouter, createMemoryRouter, createRoutesFromElements, defer, isRouteErrorResponse, Form, json, redirect, redirectDocument, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, unstable_useBlocker, useFetcher, useFetchers, useFormAction, useLoaderData, useMatches, useNavigation, unstable_usePrompt, useRevalidator, useRouteError, useRouteLoaderData, useSubmit, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_useScrollRestoration, UNSAFE_useRouteId, } from "./react-router-dom";
51
51
  export type { StaticRouterProps } from "./lib/components";
52
52
  export { CompatRouter, CompatRoute, StaticRouter } from "./lib/components";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v5 Compat v6.14.2
2
+ * React Router DOM v5 Compat v6.15.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, Routes, Route } 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
  import { parsePath, Action, createPath as createPath$1 } from 'history';
16
16
  import { Route as Route$1, useHistory } from 'react-router-dom';
@@ -100,13 +100,18 @@ function createSearchParams(init) {
100
100
  function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
101
101
  let searchParams = createSearchParams(locationSearch);
102
102
  if (defaultSearchParams) {
103
- for (let key of defaultSearchParams.keys()) {
103
+ // Use `defaultSearchParams.forEach(...)` here instead of iterating of
104
+ // `defaultSearchParams.keys()` to work-around a bug in Firefox related to
105
+ // web extensions. Relevant Bugzilla tickets:
106
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1414602
107
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1023984
108
+ defaultSearchParams.forEach((_, key) => {
104
109
  if (!searchParams.has(key)) {
105
110
  defaultSearchParams.getAll(key).forEach(value => {
106
111
  searchParams.append(key, value);
107
112
  });
108
113
  }
109
- }
114
+ });
110
115
  }
111
116
  return searchParams;
112
117
  }
@@ -810,17 +815,15 @@ function useFormAction(action, _temp2) {
810
815
  relative
811
816
  }));
812
817
  // Previously we set the default action to ".". The problem with this is that
813
- // `useResolvedPath(".")` excludes search params and the hash of the resolved
814
- // URL. This is the intended behavior of when "." is specifically provided as
818
+ // `useResolvedPath(".")` excludes search params of the resolved URL. This is
819
+ // the intended behavior of when "." is specifically provided as
815
820
  // the form action, but inconsistent w/ browsers when the action is omitted.
816
821
  // https://github.com/remix-run/remix/issues/927
817
822
  let location = useLocation();
818
823
  if (action == null) {
819
- // Safe to write to these directly here since if action was undefined, we
824
+ // Safe to write to this directly here since if action was undefined, we
820
825
  // would have called useResolvedPath(".") which will never include a search
821
- // or hash
822
826
  path.search = location.search;
823
- path.hash = location.hash;
824
827
  // When grabbing search params from the URL, remove the automatically
825
828
  // inserted ?index param so we match the useResolvedPath search behavior
826
829
  // which would not include ?index
@@ -1057,21 +1060,24 @@ function usePrompt(_ref8) {
1057
1060
  message
1058
1061
  } = _ref8;
1059
1062
  let blocker = unstable_useBlocker(when);
1060
- React.useEffect(() => {
1061
- if (blocker.state === "blocked" && !when) {
1062
- blocker.reset();
1063
- }
1064
- }, [blocker, when]);
1065
1063
  React.useEffect(() => {
1066
1064
  if (blocker.state === "blocked") {
1067
1065
  let proceed = window.confirm(message);
1068
1066
  if (proceed) {
1067
+ // This timeout is needed to avoid a weird "race" on POP navigations
1068
+ // between the `window.history` revert navigation and the result of
1069
+ // `window.confirm`
1069
1070
  setTimeout(blocker.proceed, 0);
1070
1071
  } else {
1071
1072
  blocker.reset();
1072
1073
  }
1073
1074
  }
1074
1075
  }, [blocker, message]);
1076
+ React.useEffect(() => {
1077
+ if (blocker.state === "blocked" && !when) {
1078
+ blocker.reset();
1079
+ }
1080
+ }, [blocker, when]);
1075
1081
  }
1076
1082
  //#endregion
1077
1083