react-router 6.27.0 → 6.28.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,19 @@
1
1
  # `react-router`
2
2
 
3
+ ## 6.28.0-pre.0
4
+
5
+ ### Minor Changes
6
+
7
+ - - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
8
+ - Add deprecation warnings to `json`/`defer` in favor of returning raw objects
9
+ - These methods will be removed in React Router v7
10
+
11
+ ### Patch Changes
12
+
13
+ - Update JSDoc URLs for new website structure (add /v6/ segment) ([#12141](https://github.com/remix-run/react-router/pull/12141))
14
+ - Updated dependencies:
15
+ - `@remix-run/router@1.21.0-pre.0`
16
+
3
17
  ## 6.27.0
4
18
 
5
19
  ### Minor Changes
@@ -80,7 +94,7 @@ No significant changes to this package were made in this release. [See the repo
80
94
 
81
95
  - Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
82
96
  - RFC: <https://github.com/remix-run/react-router/discussions/11113>
83
- - `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/en/main/routers/create-browser-router>
97
+ - `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/v6/routers/create-browser-router>
84
98
 
85
99
  ### Patch Changes
86
100
 
@@ -326,7 +340,7 @@ No significant changes to this package were made in this release. [See the repo
326
340
  ### Minor Changes
327
341
 
328
342
  - 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))
329
- - Remove the `unstable_` prefix from the [`useBlocker`](https://reactrouter.com/en/main/hooks/use-blocker) hook as it's been in use for enough time that we are confident in the API. We do not plan to remove the prefix from `unstable_usePrompt` due to differences in how browsers handle `window.confirm` that prevent React Router from guaranteeing consistent/correct behavior. ([#10991](https://github.com/remix-run/react-router/pull/10991))
343
+ - Remove the `unstable_` prefix from the [`useBlocker`](https://reactrouter.com/v6/hooks/use-blocker) hook as it's been in use for enough time that we are confident in the API. We do not plan to remove the prefix from `unstable_usePrompt` due to differences in how browsers handle `window.confirm` that prevent React Router from guaranteeing consistent/correct behavior. ([#10991](https://github.com/remix-run/react-router/pull/10991))
330
344
 
331
345
  ### Patch Changes
332
346
 
@@ -416,7 +430,7 @@ No significant changes to this package were made in this release. [See the repo
416
430
 
417
431
  ### Minor Changes
418
432
 
419
- - Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/en/main/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
433
+ - Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/v6/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
420
434
 
421
435
  Existing behavior will no longer include `React.startTransition`:
422
436
 
@@ -499,7 +513,7 @@ No significant changes to this package were made in this release. [See the repo
499
513
 
500
514
  ### Minor Changes
501
515
 
502
- - Added support for [**Future Flags**](https://reactrouter.com/en/main/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
516
+ - Added support for [**Future Flags**](https://reactrouter.com/v6/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
503
517
 
504
518
  - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
505
519
  - `useNavigation().formMethod` is lowercase
@@ -776,7 +790,7 @@ function Comp() {
776
790
 
777
791
  ## 6.4.0
778
792
 
779
- Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/start/overview) and the [tutorial](https://reactrouter.com/start/tutorial).
793
+ Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/en/6.4.0/start/overview) and the [tutorial](https://reactrouter.com/en/6.4.0/start/tutorial).
780
794
 
781
795
  **New APIs**
782
796
 
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ import type { DataRouteMatch, DataRouteObject, IndexRouteObject, NavigateOptions
6
6
  import { DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
7
7
  import type { NavigateFunction } from "./lib/hooks";
8
8
  import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteId, useRouteLoaderData, useRoutes, useRoutesImpl } from "./lib/hooks";
9
+ import { logV6DeprecationWarnings } from "./lib/deprecations";
9
10
  type Hash = string;
10
11
  type Pathname = string;
11
12
  type Search = string;
@@ -26,4 +27,4 @@ export declare function createMemoryRouter(routes: RouteObject[], opts?: {
26
27
  patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
27
28
  }): RemixRouter;
28
29
  /** @internal */
29
- export { DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, mapRouteProperties as UNSAFE_mapRouteProperties, useRouteId as UNSAFE_useRouteId, useRoutesImpl as UNSAFE_useRoutesImpl, };
30
+ export { DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, mapRouteProperties as UNSAFE_mapRouteProperties, useRouteId as UNSAFE_useRouteId, useRoutesImpl as UNSAFE_useRoutesImpl, logV6DeprecationWarnings as UNSAFE_logV6DeprecationWarnings, };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.27.0
2
+ * React Router v6.28.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -77,7 +77,7 @@ if (process.env.NODE_ENV !== "production") {
77
77
  * Returns the full href for the given "to" value. This is useful for building
78
78
  * custom links that are also accessible and preserve right-click behavior.
79
79
  *
80
- * @see https://reactrouter.com/hooks/use-href
80
+ * @see https://reactrouter.com/v6/hooks/use-href
81
81
  */
82
82
  function useHref(to, _temp) {
83
83
  let {
@@ -116,7 +116,7 @@ function useHref(to, _temp) {
116
116
  /**
117
117
  * Returns true if this component is a descendant of a `<Router>`.
118
118
  *
119
- * @see https://reactrouter.com/hooks/use-in-router-context
119
+ * @see https://reactrouter.com/v6/hooks/use-in-router-context
120
120
  */
121
121
  function useInRouterContext() {
122
122
  return React.useContext(LocationContext) != null;
@@ -130,7 +130,7 @@ function useInRouterContext() {
130
130
  * "routing" in your app, and we'd like to know what your use case is. We may
131
131
  * be able to provide something higher-level to better suit your needs.
132
132
  *
133
- * @see https://reactrouter.com/hooks/use-location
133
+ * @see https://reactrouter.com/v6/hooks/use-location
134
134
  */
135
135
  function useLocation() {
136
136
  !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
@@ -143,7 +143,7 @@ function useLocation() {
143
143
  * Returns the current navigation action which describes how the router came to
144
144
  * the current location, either by a pop, push, or replace on the history stack.
145
145
  *
146
- * @see https://reactrouter.com/hooks/use-navigation-type
146
+ * @see https://reactrouter.com/v6/hooks/use-navigation-type
147
147
  */
148
148
  function useNavigationType() {
149
149
  return React.useContext(LocationContext).navigationType;
@@ -154,7 +154,7 @@ function useNavigationType() {
154
154
  * This is useful for components that need to know "active" state, e.g.
155
155
  * `<NavLink>`.
156
156
  *
157
- * @see https://reactrouter.com/hooks/use-match
157
+ * @see https://reactrouter.com/v6/hooks/use-match
158
158
  */
159
159
  function useMatch(pattern) {
160
160
  !useInRouterContext() ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
@@ -187,7 +187,7 @@ function useIsomorphicLayoutEffect(cb) {
187
187
  * Returns an imperative method for changing the location. Used by `<Link>`s, but
188
188
  * may also be used by other elements to change the location.
189
189
  *
190
- * @see https://reactrouter.com/hooks/use-navigate
190
+ * @see https://reactrouter.com/v6/hooks/use-navigate
191
191
  */
192
192
  function useNavigate() {
193
193
  let {
@@ -251,7 +251,7 @@ const OutletContext = /*#__PURE__*/React.createContext(null);
251
251
  /**
252
252
  * Returns the context (if provided) for the child route at this level of the route
253
253
  * hierarchy.
254
- * @see https://reactrouter.com/hooks/use-outlet-context
254
+ * @see https://reactrouter.com/v6/hooks/use-outlet-context
255
255
  */
256
256
  function useOutletContext() {
257
257
  return React.useContext(OutletContext);
@@ -261,7 +261,7 @@ function useOutletContext() {
261
261
  * Returns the element for the child route at this level of the route
262
262
  * hierarchy. Used internally by `<Outlet>` to render child routes.
263
263
  *
264
- * @see https://reactrouter.com/hooks/use-outlet
264
+ * @see https://reactrouter.com/v6/hooks/use-outlet
265
265
  */
266
266
  function useOutlet(context) {
267
267
  let outlet = React.useContext(RouteContext).outlet;
@@ -277,7 +277,7 @@ function useOutlet(context) {
277
277
  * Returns an object of key/value pairs of the dynamic params from the current
278
278
  * URL that were matched by the route path.
279
279
  *
280
- * @see https://reactrouter.com/hooks/use-params
280
+ * @see https://reactrouter.com/v6/hooks/use-params
281
281
  */
282
282
  function useParams() {
283
283
  let {
@@ -290,7 +290,7 @@ function useParams() {
290
290
  /**
291
291
  * Resolves the pathname of the given `to` value against the current location.
292
292
  *
293
- * @see https://reactrouter.com/hooks/use-resolved-path
293
+ * @see https://reactrouter.com/v6/hooks/use-resolved-path
294
294
  */
295
295
  function useResolvedPath(to, _temp2) {
296
296
  let {
@@ -315,7 +315,7 @@ function useResolvedPath(to, _temp2) {
315
315
  * elements in the tree must render an `<Outlet>` to render their child route's
316
316
  * element.
317
317
  *
318
- * @see https://reactrouter.com/hooks/use-routes
318
+ * @see https://reactrouter.com/v6/hooks/use-routes
319
319
  */
320
320
  function useRoutes(routes, locationArg) {
321
321
  return useRoutesImpl(routes, locationArg);
@@ -690,7 +690,7 @@ var DataRouterStateHook = /*#__PURE__*/function (DataRouterStateHook) {
690
690
  return DataRouterStateHook;
691
691
  }(DataRouterStateHook || {});
692
692
  function getDataRouterConsoleError(hookName) {
693
- return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
693
+ return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
694
694
  }
695
695
  function useDataRouterContext(hookName) {
696
696
  let ctx = React.useContext(DataRouterContext);
@@ -920,14 +920,45 @@ function useNavigateStable() {
920
920
  }, [router, id]);
921
921
  return navigate;
922
922
  }
923
- const alreadyWarned = {};
923
+ const alreadyWarned$1 = {};
924
924
  function warningOnce(key, cond, message) {
925
- if (!cond && !alreadyWarned[key]) {
926
- alreadyWarned[key] = true;
925
+ if (!cond && !alreadyWarned$1[key]) {
926
+ alreadyWarned$1[key] = true;
927
927
  process.env.NODE_ENV !== "production" ? UNSAFE_warning(false, message) : void 0;
928
928
  }
929
929
  }
930
930
 
931
+ const alreadyWarned = {};
932
+ function warnOnce(key, message) {
933
+ if (!alreadyWarned[message]) {
934
+ alreadyWarned[message] = true;
935
+ console.warn(message);
936
+ }
937
+ }
938
+ const logDeprecation = (flag, msg, link) => warnOnce(flag, "\u26A0\uFE0F React Router Future Flag Warning: " + msg + ". " + ("You can use the `" + flag + "` future flag to opt-in early. ") + ("For more information, see " + link + "."));
939
+ function logV6DeprecationWarnings(renderFuture, routerFuture) {
940
+ if (!(renderFuture != null && renderFuture.v7_startTransition)) {
941
+ logDeprecation("v7_startTransition", "React Router will begin wrapping state updates in `React.startTransition` in v7", "https://reactrouter.com/v6/upgrading/future#v7_starttransition");
942
+ }
943
+ if (!(renderFuture != null && renderFuture.v7_relativeSplatPath) && (!routerFuture || !routerFuture.v7_relativeSplatPath)) {
944
+ logDeprecation("v7_relativeSplatPath", "Relative route resolution within Splat routes is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath");
945
+ }
946
+ if (routerFuture) {
947
+ if (!routerFuture.v7_fetcherPersist) {
948
+ logDeprecation("v7_fetcherPersist", "The persistence behavior of fetchers is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist");
949
+ }
950
+ if (!routerFuture.v7_normalizeFormMethod) {
951
+ logDeprecation("v7_normalizeFormMethod", "Casing of `formMethod` fields is being normalized to uppercase in v7", "https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod");
952
+ }
953
+ if (!routerFuture.v7_partialHydration) {
954
+ logDeprecation("v7_partialHydration", "`RouterProvider` hydration behavior is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_partialhydration");
955
+ }
956
+ if (!routerFuture.v7_skipActionErrorRevalidation) {
957
+ logDeprecation("v7_skipActionErrorRevalidation", "The revalidation behavior after 4xx/5xx `action` responses is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation");
958
+ }
959
+ }
960
+ }
961
+
931
962
  /**
932
963
  Webpack + React 17 fails to compile on any of the following because webpack
933
964
  complains that `startTransition` doesn't exist in `React`:
@@ -1004,6 +1035,7 @@ function RouterProvider(_ref) {
1004
1035
  static: false,
1005
1036
  basename
1006
1037
  }), [router, navigator, basename]);
1038
+ React.useEffect(() => logV6DeprecationWarnings(future, router.future), [router, future]);
1007
1039
 
1008
1040
  // The fragment and {null} here are important! We need them to keep React 18's
1009
1041
  // useId happy when we are server-rendering since we may have a <script> here
@@ -1040,7 +1072,7 @@ function DataRoutes(_ref2) {
1040
1072
  /**
1041
1073
  * A `<Router>` that stores all entries in memory.
1042
1074
  *
1043
- * @see https://reactrouter.com/router-components/memory-router
1075
+ * @see https://reactrouter.com/v6/router-components/memory-router
1044
1076
  */
1045
1077
  function MemoryRouter(_ref3) {
1046
1078
  let {
@@ -1070,6 +1102,7 @@ function MemoryRouter(_ref3) {
1070
1102
  v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
1071
1103
  }, [setStateImpl, v7_startTransition]);
1072
1104
  React.useLayoutEffect(() => history.listen(setState), [history, setState]);
1105
+ React.useEffect(() => logV6DeprecationWarnings(future), [future]);
1073
1106
  return /*#__PURE__*/React.createElement(Router, {
1074
1107
  basename: basename,
1075
1108
  children: children,
@@ -1086,7 +1119,7 @@ function MemoryRouter(_ref3) {
1086
1119
  * able to use hooks. In functional components, we recommend you use the
1087
1120
  * `useNavigate` hook instead.
1088
1121
  *
1089
- * @see https://reactrouter.com/components/navigate
1122
+ * @see https://reactrouter.com/v6/components/navigate
1090
1123
  */
1091
1124
  function Navigate(_ref4) {
1092
1125
  let {
@@ -1125,7 +1158,7 @@ function Navigate(_ref4) {
1125
1158
  /**
1126
1159
  * Renders the child route's element, if there is one.
1127
1160
  *
1128
- * @see https://reactrouter.com/components/outlet
1161
+ * @see https://reactrouter.com/v6/components/outlet
1129
1162
  */
1130
1163
  function Outlet(props) {
1131
1164
  return useOutlet(props.context);
@@ -1133,7 +1166,7 @@ function Outlet(props) {
1133
1166
  /**
1134
1167
  * Declares an element that should be rendered at a certain URL path.
1135
1168
  *
1136
- * @see https://reactrouter.com/components/route
1169
+ * @see https://reactrouter.com/v6/components/route
1137
1170
  */
1138
1171
  function Route(_props) {
1139
1172
  process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, " + "never rendered directly. Please wrap your <Route> in a <Routes>.") : UNSAFE_invariant(false) ;
@@ -1145,7 +1178,7 @@ function Route(_props) {
1145
1178
  * router that is more specific to your environment such as a `<BrowserRouter>`
1146
1179
  * in web browsers or a `<StaticRouter>` for server rendering.
1147
1180
  *
1148
- * @see https://reactrouter.com/router-components/router
1181
+ * @see https://reactrouter.com/v6/router-components/router
1149
1182
  */
1150
1183
  function Router(_ref5) {
1151
1184
  let {
@@ -1211,7 +1244,7 @@ function Router(_ref5) {
1211
1244
  * A container for a nested tree of `<Route>` elements that renders the branch
1212
1245
  * that best matches the current location.
1213
1246
  *
1214
- * @see https://reactrouter.com/components/routes
1247
+ * @see https://reactrouter.com/v6/components/routes
1215
1248
  */
1216
1249
  function Routes(_ref6) {
1217
1250
  let {
@@ -1352,7 +1385,7 @@ function ResolveAwait(_ref8) {
1352
1385
  * either a `<Route>` element or an array of them. Used internally by
1353
1386
  * `<Routes>` to create a route config from its children.
1354
1387
  *
1355
- * @see https://reactrouter.com/utils/create-routes-from-children
1388
+ * @see https://reactrouter.com/v6/utils/create-routes-from-children
1356
1389
  */
1357
1390
  function createRoutesFromChildren(children, parentPath) {
1358
1391
  if (parentPath === void 0) {
@@ -1463,5 +1496,5 @@ function createMemoryRouter(routes, opts) {
1463
1496
  }).initialize();
1464
1497
  }
1465
1498
 
1466
- export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, mapRouteProperties as UNSAFE_mapRouteProperties, useRouteId as UNSAFE_useRouteId, useRoutesImpl as UNSAFE_useRoutesImpl, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1499
+ export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, logV6DeprecationWarnings as UNSAFE_logV6DeprecationWarnings, mapRouteProperties as UNSAFE_mapRouteProperties, useRouteId as UNSAFE_useRouteId, useRoutesImpl as UNSAFE_useRoutesImpl, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1467
1500
  //# sourceMappingURL=index.js.map