react-router-dom 0.0.0-experimental-e192105b → 0.0.0-experimental-178bc9ee

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.19.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `unstable_flushSync` option to `useNavigate`/`useSumbit`/`fetcher.load`/`fetcher.submit` to opt-out of `React.startTransition` and into `ReactDOM.flushSync` for state updates ([#11005](https://github.com/remix-run/react-router/pull/11005))
8
+ - Allow `unstable_usePrompt` to accept a `BlockerFunction` in addition to a `boolean` ([#10991](https://github.com/remix-run/react-router/pull/10991))
9
+
10
+ ### Patch Changes
11
+
12
+ - Fix issue where a changing fetcher `key` in a `useFetcher` that remains mounted wasn't getting picked up ([#11009](https://github.com/remix-run/react-router/pull/11009))
13
+ - Fix `useFormAction` which was incorrectly inheriting the `?index` query param from child route `action` submissions ([#11025](https://github.com/remix-run/react-router/pull/11025))
14
+ - Fix `NavLink` `active` logic when `to` location has a trailing slash ([#10734](https://github.com/remix-run/react-router/pull/10734))
15
+ - Updated dependencies:
16
+ - `react-router@6.19.0`
17
+ - `@remix-run/router@1.12.0`
18
+
3
19
  ## 6.18.0
4
20
 
5
21
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit, SubmitTarge
9
9
  import { createSearchParams } from "./dom";
10
10
  export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
11
11
  export { createSearchParams };
12
- export type { ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, ErrorResponse, 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, ShouldRevalidateFunctionArgs, To, UIMatch, } from "react-router";
12
+ export type { ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, ErrorResponse, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathParam, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, } from "react-router";
13
13
  export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, 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";
@@ -95,7 +95,6 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
95
95
  preventScrollReset?: boolean;
96
96
  relative?: RelativeRoutingType;
97
97
  to: To;
98
- unstable_flushSync?: boolean;
99
98
  unstable_viewTransition?: boolean;
100
99
  }
101
100
  /**
@@ -173,10 +172,6 @@ export interface FormProps extends FetcherFormProps {
173
172
  * State object to add to the history stack entry for this navigation
174
173
  */
175
174
  state?: any;
176
- /**
177
- * Enable flushSync navigation's staten updates
178
- */
179
- unstable_flushSync?: boolean;
180
175
  /**
181
176
  * Enable view transitions on this Form navigation
182
177
  */
@@ -206,13 +201,12 @@ export declare namespace ScrollRestoration {
206
201
  * you need to create custom `<Link>` components with the same click behavior we
207
202
  * use in our exported `<Link>`.
208
203
  */
209
- export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, unstable_flushSync, unstable_viewTransition, }?: {
204
+ export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, unstable_viewTransition, }?: {
210
205
  target?: React.HTMLAttributeAnchorTarget;
211
206
  replace?: boolean;
212
207
  state?: any;
213
208
  preventScrollReset?: boolean;
214
209
  relative?: RelativeRoutingType;
215
- unstable_flushSync?: boolean;
216
210
  unstable_viewTransition?: boolean;
217
211
  }): (event: React.MouseEvent<E, MouseEvent>) => void;
218
212
  /**
@@ -258,7 +252,9 @@ export declare function useFormAction(action?: string, { relative }?: {
258
252
  export type FetcherWithComponents<TData> = Fetcher<TData> & {
259
253
  Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
260
254
  submit: FetcherSubmitFunction;
261
- load: (href: string) => void;
255
+ load: (href: string, opts?: {
256
+ unstable_flushSync?: boolean;
257
+ }) => void;
262
258
  };
263
259
  /**
264
260
  * Interacts with route loaders and actions without causing a navigation. Great
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v0.0.0-experimental-e192105b
2
+ * React Router DOM v0.0.0-experimental-178bc9ee
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -207,9 +207,9 @@ function getFormSubmissionInfo(target, basename) {
207
207
  };
208
208
  }
209
209
 
210
- const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_flushSync", "unstable_viewTransition"],
210
+ const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_viewTransition"],
211
211
  _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "unstable_viewTransition", "children"],
212
- _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_flushSync", "unstable_viewTransition"];
212
+ _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_viewTransition"];
213
213
  function createBrowserRouter(routes, opts) {
214
214
  return createRouter({
215
215
  basename: opts == null ? void 0 : opts.basename,
@@ -521,6 +521,11 @@ function RouterProvider(_ref) {
521
521
  setInterruption(undefined);
522
522
  }
523
523
  }, [vtContext.isTransitioning, interruption]);
524
+ React.useEffect(() => {
525
+ process.env.NODE_ENV !== "production" ? UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`") : void 0;
526
+ // Only log this once on initial mount
527
+ // eslint-disable-next-line react-hooks/exhaustive-deps
528
+ }, []);
524
529
  let navigator = React.useMemo(() => {
525
530
  return {
526
531
  createHref: router.createHref,
@@ -565,15 +570,17 @@ function RouterProvider(_ref) {
565
570
  navigator: navigator
566
571
  }, state.initialized ? /*#__PURE__*/React.createElement(DataRoutes, {
567
572
  routes: router.routes,
573
+ future: router.future,
568
574
  state: state
569
575
  }) : fallbackElement))))), null);
570
576
  }
571
577
  function DataRoutes(_ref3) {
572
578
  let {
573
579
  routes,
580
+ future,
574
581
  state
575
582
  } = _ref3;
576
- return UNSAFE_useRoutesImpl(routes, undefined, state);
583
+ return UNSAFE_useRoutesImpl(routes, undefined, state, future);
577
584
  }
578
585
  /**
579
586
  * A `<Router>` for use in web browsers. Provides the cleanest URLs.
@@ -700,7 +707,6 @@ const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref7, ref) {
700
707
  target,
701
708
  to,
702
709
  preventScrollReset,
703
- unstable_flushSync,
704
710
  unstable_viewTransition
705
711
  } = _ref7,
706
712
  rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
@@ -741,7 +747,6 @@ const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref7, ref) {
741
747
  target,
742
748
  preventScrollReset,
743
749
  relative,
744
- unstable_flushSync,
745
750
  unstable_viewTransition
746
751
  });
747
752
  function handleClick(event) {
@@ -855,7 +860,6 @@ const Form = /*#__PURE__*/React.forwardRef((_ref9, forwardedRef) => {
855
860
  onSubmit,
856
861
  relative,
857
862
  preventScrollReset,
858
- unstable_flushSync,
859
863
  unstable_viewTransition
860
864
  } = _ref9,
861
865
  props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
@@ -878,7 +882,6 @@ const Form = /*#__PURE__*/React.forwardRef((_ref9, forwardedRef) => {
878
882
  state,
879
883
  relative,
880
884
  preventScrollReset,
881
- unstable_flushSync,
882
885
  unstable_viewTransition
883
886
  });
884
887
  };
@@ -955,7 +958,6 @@ function useLinkClickHandler(to, _temp) {
955
958
  state,
956
959
  preventScrollReset,
957
960
  relative,
958
- unstable_flushSync,
959
961
  unstable_viewTransition
960
962
  } = _temp === void 0 ? {} : _temp;
961
963
  let navigate = useNavigate();
@@ -974,11 +976,10 @@ function useLinkClickHandler(to, _temp) {
974
976
  state,
975
977
  preventScrollReset,
976
978
  relative,
977
- unstable_flushSync,
978
979
  unstable_viewTransition
979
980
  });
980
981
  }
981
- }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_flushSync, unstable_viewTransition]);
982
+ }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_viewTransition]);
982
983
  }
983
984
  /**
984
985
  * A convenient wrapper for reading and writing search parameters via the
@@ -1084,11 +1085,11 @@ function useFormAction(action, _temp2) {
1084
1085
  // Safe to write to this directly here since if action was undefined, we
1085
1086
  // would have called useResolvedPath(".") which will never include a search
1086
1087
  path.search = location.search;
1087
- // When grabbing search params from the URL, remove the automatically
1088
- // inserted ?index param so we match the useResolvedPath search behavior
1089
- // which would not include ?index
1090
- if (match.route.index) {
1091
- let params = new URLSearchParams(path.search);
1088
+ // When grabbing search params from the URL, remove any included ?index param
1089
+ // since it might not apply to our contextual route. We add it back based
1090
+ // on match.route.index below
1091
+ let params = new URLSearchParams(path.search);
1092
+ if (params.has("index") && params.get("index") === "") {
1092
1093
  params.delete("index");
1093
1094
  path.search = params.toString() ? "?" + params.toString() : "";
1094
1095
  }
@@ -1127,7 +1128,9 @@ function useFetcher(_temp3) {
1127
1128
  !(routeId != null) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFetcher can only be used on routes that contain a unique \"id\"") : UNSAFE_invariant(false) : void 0;
1128
1129
  // Fetcher key handling
1129
1130
  let [fetcherKey, setFetcherKey] = React.useState(key || "");
1130
- if (!fetcherKey) {
1131
+ if (key && key !== fetcherKey) {
1132
+ setFetcherKey(key);
1133
+ } else if (!fetcherKey) {
1131
1134
  setFetcherKey(getUniqueFetcherId());
1132
1135
  }
1133
1136
  // Registration/cleanup