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.
@@ -25,7 +25,7 @@ export interface MemoryRouterProps {
25
25
  /**
26
26
  * A `<Router>` that stores all entries in memory.
27
27
  *
28
- * @see https://reactrouter.com/router-components/memory-router
28
+ * @see https://reactrouter.com/v6/router-components/memory-router
29
29
  */
30
30
  export declare function MemoryRouter({ basename, children, initialEntries, initialIndex, future, }: MemoryRouterProps): React.ReactElement;
31
31
  export interface NavigateProps {
@@ -41,7 +41,7 @@ export interface NavigateProps {
41
41
  * able to use hooks. In functional components, we recommend you use the
42
42
  * `useNavigate` hook instead.
43
43
  *
44
- * @see https://reactrouter.com/components/navigate
44
+ * @see https://reactrouter.com/v6/components/navigate
45
45
  */
46
46
  export declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
47
47
  export interface OutletProps {
@@ -50,7 +50,7 @@ export interface OutletProps {
50
50
  /**
51
51
  * Renders the child route's element, if there is one.
52
52
  *
53
- * @see https://reactrouter.com/components/outlet
53
+ * @see https://reactrouter.com/v6/components/outlet
54
54
  */
55
55
  export declare function Outlet(props: OutletProps): React.ReactElement | null;
56
56
  export interface PathRouteProps {
@@ -97,7 +97,7 @@ export type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
97
97
  /**
98
98
  * Declares an element that should be rendered at a certain URL path.
99
99
  *
100
- * @see https://reactrouter.com/components/route
100
+ * @see https://reactrouter.com/v6/components/route
101
101
  */
102
102
  export declare function Route(_props: RouteProps): React.ReactElement | null;
103
103
  export interface RouterProps {
@@ -116,7 +116,7 @@ export interface RouterProps {
116
116
  * router that is more specific to your environment such as a `<BrowserRouter>`
117
117
  * in web browsers or a `<StaticRouter>` for server rendering.
118
118
  *
119
- * @see https://reactrouter.com/router-components/router
119
+ * @see https://reactrouter.com/v6/router-components/router
120
120
  */
121
121
  export declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, future, }: RouterProps): React.ReactElement | null;
122
122
  export interface RoutesProps {
@@ -127,7 +127,7 @@ export interface RoutesProps {
127
127
  * A container for a nested tree of `<Route>` elements that renders the branch
128
128
  * that best matches the current location.
129
129
  *
130
- * @see https://reactrouter.com/components/routes
130
+ * @see https://reactrouter.com/v6/components/routes
131
131
  */
132
132
  export declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
133
133
  export interface AwaitResolveRenderFunction {
@@ -148,7 +148,7 @@ export declare function Await({ children, errorElement, resolve }: AwaitProps):
148
148
  * either a `<Route>` element or an array of them. Used internally by
149
149
  * `<Routes>` to create a route config from its children.
150
150
  *
151
- * @see https://reactrouter.com/utils/create-routes-from-children
151
+ * @see https://reactrouter.com/v6/utils/create-routes-from-children
152
152
  */
153
153
  export declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
154
154
  /**
@@ -0,0 +1,4 @@
1
+ import type { FutureConfig as RouterFutureConfig } from "@remix-run/router";
2
+ import type { FutureConfig as RenderFutureConfig } from "./components";
3
+ export declare function warnOnce(key: string, message: string): void;
4
+ export declare function logV6DeprecationWarnings(renderFuture: Partial<RenderFutureConfig> | undefined, routerFuture?: Omit<RouterFutureConfig, "v7_prependBasename">): void;
@@ -6,7 +6,7 @@ import type { NavigateOptions, RouteContextObject, RouteMatch, RouteObject } fro
6
6
  * Returns the full href for the given "to" value. This is useful for building
7
7
  * custom links that are also accessible and preserve right-click behavior.
8
8
  *
9
- * @see https://reactrouter.com/hooks/use-href
9
+ * @see https://reactrouter.com/v6/hooks/use-href
10
10
  */
11
11
  export declare function useHref(to: To, { relative }?: {
12
12
  relative?: RelativeRoutingType;
@@ -14,7 +14,7 @@ export declare function useHref(to: To, { relative }?: {
14
14
  /**
15
15
  * Returns true if this component is a descendant of a `<Router>`.
16
16
  *
17
- * @see https://reactrouter.com/hooks/use-in-router-context
17
+ * @see https://reactrouter.com/v6/hooks/use-in-router-context
18
18
  */
19
19
  export declare function useInRouterContext(): boolean;
20
20
  /**
@@ -25,14 +25,14 @@ export declare function useInRouterContext(): boolean;
25
25
  * "routing" in your app, and we'd like to know what your use case is. We may
26
26
  * be able to provide something higher-level to better suit your needs.
27
27
  *
28
- * @see https://reactrouter.com/hooks/use-location
28
+ * @see https://reactrouter.com/v6/hooks/use-location
29
29
  */
30
30
  export declare function useLocation(): Location;
31
31
  /**
32
32
  * Returns the current navigation action which describes how the router came to
33
33
  * the current location, either by a pop, push, or replace on the history stack.
34
34
  *
35
- * @see https://reactrouter.com/hooks/use-navigation-type
35
+ * @see https://reactrouter.com/v6/hooks/use-navigation-type
36
36
  */
37
37
  export declare function useNavigationType(): NavigationType;
38
38
  /**
@@ -40,7 +40,7 @@ export declare function useNavigationType(): NavigationType;
40
40
  * This is useful for components that need to know "active" state, e.g.
41
41
  * `<NavLink>`.
42
42
  *
43
- * @see https://reactrouter.com/hooks/use-match
43
+ * @see https://reactrouter.com/v6/hooks/use-match
44
44
  */
45
45
  export declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
46
46
  /**
@@ -54,27 +54,27 @@ export interface NavigateFunction {
54
54
  * Returns an imperative method for changing the location. Used by `<Link>`s, but
55
55
  * may also be used by other elements to change the location.
56
56
  *
57
- * @see https://reactrouter.com/hooks/use-navigate
57
+ * @see https://reactrouter.com/v6/hooks/use-navigate
58
58
  */
59
59
  export declare function useNavigate(): NavigateFunction;
60
60
  /**
61
61
  * Returns the context (if provided) for the child route at this level of the route
62
62
  * hierarchy.
63
- * @see https://reactrouter.com/hooks/use-outlet-context
63
+ * @see https://reactrouter.com/v6/hooks/use-outlet-context
64
64
  */
65
65
  export declare function useOutletContext<Context = unknown>(): Context;
66
66
  /**
67
67
  * Returns the element for the child route at this level of the route
68
68
  * hierarchy. Used internally by `<Outlet>` to render child routes.
69
69
  *
70
- * @see https://reactrouter.com/hooks/use-outlet
70
+ * @see https://reactrouter.com/v6/hooks/use-outlet
71
71
  */
72
72
  export declare function useOutlet(context?: unknown): React.ReactElement | null;
73
73
  /**
74
74
  * Returns an object of key/value pairs of the dynamic params from the current
75
75
  * URL that were matched by the route path.
76
76
  *
77
- * @see https://reactrouter.com/hooks/use-params
77
+ * @see https://reactrouter.com/v6/hooks/use-params
78
78
  */
79
79
  export declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
80
80
  ParamsOrKey
@@ -82,7 +82,7 @@ export declare function useParams<ParamsOrKey extends string | Record<string, st
82
82
  /**
83
83
  * Resolves the pathname of the given `to` value against the current location.
84
84
  *
85
- * @see https://reactrouter.com/hooks/use-resolved-path
85
+ * @see https://reactrouter.com/v6/hooks/use-resolved-path
86
86
  */
87
87
  export declare function useResolvedPath(to: To, { relative }?: {
88
88
  relative?: RelativeRoutingType;
@@ -93,7 +93,7 @@ export declare function useResolvedPath(to: To, { relative }?: {
93
93
  * elements in the tree must render an `<Outlet>` to render their child route's
94
94
  * element.
95
95
  *
96
- * @see https://reactrouter.com/hooks/use-routes
96
+ * @see https://reactrouter.com/v6/hooks/use-routes
97
97
  */
98
98
  export declare function useRoutes(routes: RouteObject[], locationArg?: Partial<Location> | string): React.ReactElement | null;
99
99
  export declare function useRoutesImpl(routes: RouteObject[], locationArg?: Partial<Location> | string, dataRouterState?: RemixRouter["state"], future?: RemixRouter["future"]): React.ReactElement | null;
package/dist/main.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
  *
@@ -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
  *
@@ -49,7 +49,7 @@ const RouteErrorContext = /*#__PURE__*/React.createContext(null);
49
49
  * Returns the full href for the given "to" value. This is useful for building
50
50
  * custom links that are also accessible and preserve right-click behavior.
51
51
  *
52
- * @see https://reactrouter.com/hooks/use-href
52
+ * @see https://reactrouter.com/v6/hooks/use-href
53
53
  */
54
54
  function useHref(to, {
55
55
  relative
@@ -86,7 +86,7 @@ function useHref(to, {
86
86
  /**
87
87
  * Returns true if this component is a descendant of a `<Router>`.
88
88
  *
89
- * @see https://reactrouter.com/hooks/use-in-router-context
89
+ * @see https://reactrouter.com/v6/hooks/use-in-router-context
90
90
  */
91
91
  function useInRouterContext() {
92
92
  return React.useContext(LocationContext) != null;
@@ -99,7 +99,7 @@ function useInRouterContext() {
99
99
  * "routing" in your app, and we'd like to know what your use case is. We may
100
100
  * be able to provide something higher-level to better suit your needs.
101
101
  *
102
- * @see https://reactrouter.com/hooks/use-location
102
+ * @see https://reactrouter.com/v6/hooks/use-location
103
103
  */
104
104
  function useLocation() {
105
105
  !useInRouterContext() ? UNSAFE_invariant(false,
@@ -112,7 +112,7 @@ function useLocation() {
112
112
  * Returns the current navigation action which describes how the router came to
113
113
  * the current location, either by a pop, push, or replace on the history stack.
114
114
  *
115
- * @see https://reactrouter.com/hooks/use-navigation-type
115
+ * @see https://reactrouter.com/v6/hooks/use-navigation-type
116
116
  */
117
117
  function useNavigationType() {
118
118
  return React.useContext(LocationContext).navigationType;
@@ -122,7 +122,7 @@ function useNavigationType() {
122
122
  * This is useful for components that need to know "active" state, e.g.
123
123
  * `<NavLink>`.
124
124
  *
125
- * @see https://reactrouter.com/hooks/use-match
125
+ * @see https://reactrouter.com/v6/hooks/use-match
126
126
  */
127
127
  function useMatch(pattern) {
128
128
  !useInRouterContext() ? UNSAFE_invariant(false,
@@ -149,7 +149,7 @@ function useIsomorphicLayoutEffect(cb) {
149
149
  * Returns an imperative method for changing the location. Used by `<Link>`s, but
150
150
  * may also be used by other elements to change the location.
151
151
  *
152
- * @see https://reactrouter.com/hooks/use-navigate
152
+ * @see https://reactrouter.com/v6/hooks/use-navigate
153
153
  */
154
154
  function useNavigate() {
155
155
  let {
@@ -208,7 +208,7 @@ const OutletContext = /*#__PURE__*/React.createContext(null);
208
208
  /**
209
209
  * Returns the context (if provided) for the child route at this level of the route
210
210
  * hierarchy.
211
- * @see https://reactrouter.com/hooks/use-outlet-context
211
+ * @see https://reactrouter.com/v6/hooks/use-outlet-context
212
212
  */
213
213
  function useOutletContext() {
214
214
  return React.useContext(OutletContext);
@@ -217,7 +217,7 @@ function useOutletContext() {
217
217
  * Returns the element for the child route at this level of the route
218
218
  * hierarchy. Used internally by `<Outlet>` to render child routes.
219
219
  *
220
- * @see https://reactrouter.com/hooks/use-outlet
220
+ * @see https://reactrouter.com/v6/hooks/use-outlet
221
221
  */
222
222
  function useOutlet(context) {
223
223
  let outlet = React.useContext(RouteContext).outlet;
@@ -232,7 +232,7 @@ function useOutlet(context) {
232
232
  * Returns an object of key/value pairs of the dynamic params from the current
233
233
  * URL that were matched by the route path.
234
234
  *
235
- * @see https://reactrouter.com/hooks/use-params
235
+ * @see https://reactrouter.com/v6/hooks/use-params
236
236
  */
237
237
  function useParams() {
238
238
  let {
@@ -244,7 +244,7 @@ function useParams() {
244
244
  /**
245
245
  * Resolves the pathname of the given `to` value against the current location.
246
246
  *
247
- * @see https://reactrouter.com/hooks/use-resolved-path
247
+ * @see https://reactrouter.com/v6/hooks/use-resolved-path
248
248
  */
249
249
  function useResolvedPath(to, {
250
250
  relative
@@ -267,7 +267,7 @@ function useResolvedPath(to, {
267
267
  * elements in the tree must render an `<Outlet>` to render their child route's
268
268
  * element.
269
269
  *
270
- * @see https://reactrouter.com/hooks/use-routes
270
+ * @see https://reactrouter.com/v6/hooks/use-routes
271
271
  */
272
272
  function useRoutes(routes, locationArg) {
273
273
  return useRoutesImpl(routes, locationArg);
@@ -625,7 +625,7 @@ var DataRouterStateHook;
625
625
  DataRouterStateHook["UseRouteId"] = "useRouteId";
626
626
  })(DataRouterStateHook || (DataRouterStateHook = {}));
627
627
  function getDataRouterConsoleError(hookName) {
628
- return `${hookName} must be used within a data router. See https://reactrouter.com/routers/picking-a-router.`;
628
+ return `${hookName} must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.`;
629
629
  }
630
630
  function useDataRouterContext(hookName) {
631
631
  let ctx = React.useContext(DataRouterContext);
@@ -834,14 +834,45 @@ function useNavigateStable() {
834
834
  }, [router, id]);
835
835
  return navigate;
836
836
  }
837
- const alreadyWarned = {};
837
+ const alreadyWarned$1 = {};
838
838
  function warningOnce(key, cond, message) {
839
- if (!cond && !alreadyWarned[key]) {
840
- alreadyWarned[key] = true;
839
+ if (!cond && !alreadyWarned$1[key]) {
840
+ alreadyWarned$1[key] = true;
841
841
  UNSAFE_warning(false, message) ;
842
842
  }
843
843
  }
844
844
 
845
+ const alreadyWarned = {};
846
+ function warnOnce(key, message) {
847
+ if (!alreadyWarned[message]) {
848
+ alreadyWarned[message] = true;
849
+ console.warn(message);
850
+ }
851
+ }
852
+ const logDeprecation = (flag, msg, link) => warnOnce(flag, `⚠️ React Router Future Flag Warning: ${msg}. ` + `You can use the \`${flag}\` future flag to opt-in early. ` + `For more information, see ${link}.`);
853
+ function logV6DeprecationWarnings(renderFuture, routerFuture) {
854
+ if (!renderFuture?.v7_startTransition) {
855
+ logDeprecation("v7_startTransition", "React Router will begin wrapping state updates in `React.startTransition` in v7", "https://reactrouter.com/v6/upgrading/future#v7_starttransition");
856
+ }
857
+ if (!renderFuture?.v7_relativeSplatPath && (!routerFuture || !routerFuture.v7_relativeSplatPath)) {
858
+ logDeprecation("v7_relativeSplatPath", "Relative route resolution within Splat routes is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath");
859
+ }
860
+ if (routerFuture) {
861
+ if (!routerFuture.v7_fetcherPersist) {
862
+ logDeprecation("v7_fetcherPersist", "The persistence behavior of fetchers is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist");
863
+ }
864
+ if (!routerFuture.v7_normalizeFormMethod) {
865
+ logDeprecation("v7_normalizeFormMethod", "Casing of `formMethod` fields is being normalized to uppercase in v7", "https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod");
866
+ }
867
+ if (!routerFuture.v7_partialHydration) {
868
+ logDeprecation("v7_partialHydration", "`RouterProvider` hydration behavior is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_partialhydration");
869
+ }
870
+ if (!routerFuture.v7_skipActionErrorRevalidation) {
871
+ logDeprecation("v7_skipActionErrorRevalidation", "The revalidation behavior after 4xx/5xx `action` responses is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation");
872
+ }
873
+ }
874
+ }
875
+
845
876
  /**
846
877
  Webpack + React 17 fails to compile on any of the following because webpack
847
878
  complains that `startTransition` doesn't exist in `React`:
@@ -915,6 +946,7 @@ function RouterProvider({
915
946
  static: false,
916
947
  basename
917
948
  }), [router, navigator, basename]);
949
+ React.useEffect(() => logV6DeprecationWarnings(future, router.future), [router, future]);
918
950
  // The fragment and {null} here are important! We need them to keep React 18's
919
951
  // useId happy when we are server-rendering since we may have a <script> here
920
952
  // containing the hydrated server-side staticContext (from StaticRouterProvider).
@@ -949,7 +981,7 @@ function DataRoutes({
949
981
  /**
950
982
  * A `<Router>` that stores all entries in memory.
951
983
  *
952
- * @see https://reactrouter.com/router-components/memory-router
984
+ * @see https://reactrouter.com/v6/router-components/memory-router
953
985
  */
954
986
  function MemoryRouter({
955
987
  basename,
@@ -978,6 +1010,7 @@ function MemoryRouter({
978
1010
  v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
979
1011
  }, [setStateImpl, v7_startTransition]);
980
1012
  React.useLayoutEffect(() => history.listen(setState), [history, setState]);
1013
+ React.useEffect(() => logV6DeprecationWarnings(future), [future]);
981
1014
  return /*#__PURE__*/React.createElement(Router, {
982
1015
  basename: basename,
983
1016
  children: children,
@@ -994,7 +1027,7 @@ function MemoryRouter({
994
1027
  * able to use hooks. In functional components, we recommend you use the
995
1028
  * `useNavigate` hook instead.
996
1029
  *
997
- * @see https://reactrouter.com/components/navigate
1030
+ * @see https://reactrouter.com/v6/components/navigate
998
1031
  */
999
1032
  function Navigate({
1000
1033
  to,
@@ -1032,7 +1065,7 @@ function Navigate({
1032
1065
  /**
1033
1066
  * Renders the child route's element, if there is one.
1034
1067
  *
1035
- * @see https://reactrouter.com/components/outlet
1068
+ * @see https://reactrouter.com/v6/components/outlet
1036
1069
  */
1037
1070
  function Outlet(props) {
1038
1071
  return useOutlet(props.context);
@@ -1040,7 +1073,7 @@ function Outlet(props) {
1040
1073
  /**
1041
1074
  * Declares an element that should be rendered at a certain URL path.
1042
1075
  *
1043
- * @see https://reactrouter.com/components/route
1076
+ * @see https://reactrouter.com/v6/components/route
1044
1077
  */
1045
1078
  function Route(_props) {
1046
1079
  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>.`) ;
@@ -1052,7 +1085,7 @@ function Route(_props) {
1052
1085
  * router that is more specific to your environment such as a `<BrowserRouter>`
1053
1086
  * in web browsers or a `<StaticRouter>` for server rendering.
1054
1087
  *
1055
- * @see https://reactrouter.com/router-components/router
1088
+ * @see https://reactrouter.com/v6/router-components/router
1056
1089
  */
1057
1090
  function Router({
1058
1091
  basename: basenameProp = "/",
@@ -1117,7 +1150,7 @@ function Router({
1117
1150
  * A container for a nested tree of `<Route>` elements that renders the branch
1118
1151
  * that best matches the current location.
1119
1152
  *
1120
- * @see https://reactrouter.com/components/routes
1153
+ * @see https://reactrouter.com/v6/components/routes
1121
1154
  */
1122
1155
  function Routes({
1123
1156
  children,
@@ -1251,7 +1284,7 @@ function ResolveAwait({
1251
1284
  * either a `<Route>` element or an array of them. Used internally by
1252
1285
  * `<Routes>` to create a route config from its children.
1253
1286
  *
1254
- * @see https://reactrouter.com/utils/create-routes-from-children
1287
+ * @see https://reactrouter.com/v6/utils/create-routes-from-children
1255
1288
  */
1256
1289
  function createRoutesFromChildren(children, parentPath = []) {
1257
1290
  let routes = [];
@@ -1359,5 +1392,5 @@ function createMemoryRouter(routes, opts) {
1359
1392
  }).initialize();
1360
1393
  }
1361
1394
 
1362
- 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 };
1395
+ 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 };
1363
1396
  //# sourceMappingURL=react-router.development.js.map