react-router-dom 0.0.0-experimental-c9f8a7b2 → 0.0.0-experimental-e960cf1a

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,177 +1,10 @@
1
1
  # `react-router-dom`
2
2
 
3
- ## 6.21.3
4
-
5
- ### Patch Changes
6
-
7
- - Fix `NavLink` `isPending` when a `basename` is used ([#11195](https://github.com/remix-run/react-router/pull/11195))
8
- - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
9
- - Updated dependencies:
10
- - `react-router@6.21.3`
11
-
12
- ## 6.21.2
13
-
14
- ### Patch Changes
15
-
16
- - Leverage `useId` for internal fetcher keys when available ([#11166](https://github.com/remix-run/react-router/pull/11166))
17
- - Updated dependencies:
18
- - `@remix-run/router@1.14.2`
19
- - `react-router@6.21.2`
20
-
21
- ## 6.21.1
22
-
23
- ### Patch Changes
24
-
25
- - Updated dependencies:
26
- - `react-router@6.21.1`
27
- - `@remix-run/router@1.14.1`
28
-
29
- ## 6.21.0
30
-
31
- ### Minor Changes
32
-
33
- - Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
34
-
35
- This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
36
-
37
- **The Bug**
38
- The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
39
-
40
- **The Background**
41
- This decision was originally made thinking that it would make the concept of nested different sections of your apps in `<Routes>` easier if relative routing would _replace_ the current splat:
42
-
43
- ```jsx
44
- <BrowserRouter>
45
- <Routes>
46
- <Route path="/" element={<Home />} />
47
- <Route path="dashboard/*" element={<Dashboard />} />
48
- </Routes>
49
- </BrowserRouter>
50
- ```
51
-
52
- Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
53
-
54
- ```jsx
55
- function Dashboard() {
56
- return (
57
- <div>
58
- <h2>Dashboard</h2>
59
- <nav>
60
- <Link to="/">Dashboard Home</Link>
61
- <Link to="team">Team</Link>
62
- <Link to="projects">Projects</Link>
63
- </nav>
64
-
65
- <Routes>
66
- <Route path="/" element={<DashboardHome />} />
67
- <Route path="team" element={<DashboardTeam />} />
68
- <Route path="projects" element={<DashboardProjects />} />
69
- </Routes>
70
- </div>
71
- );
72
- }
73
- ```
74
-
75
- Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the `Dashboard` as its own independent app, or embed it into your large app without making any changes to it.
76
-
77
- **The Problem**
78
-
79
- The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
80
-
81
- ```jsx
82
- // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
83
- function DashboardTeam() {
84
- // ❌ This is broken and results in <a href="/dashboard">
85
- return <Link to=".">A broken link to the Current URL</Link>;
86
-
87
- // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
88
- return <Link to="./team">A broken link to the Current URL</Link>;
89
- }
90
- ```
91
-
92
- We've also introduced an issue that we can no longer move our `DashboardTeam` component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as `/dashboard/:widget`. Now, our `"."` links will, properly point to ourself _inclusive of the dynamic param value_ so behavior will break from it's corresponding usage in a `/dashboard/*` route.
93
-
94
- Even worse, consider a nested splat route configuration:
95
-
96
- ```jsx
97
- <BrowserRouter>
98
- <Routes>
99
- <Route path="dashboard">
100
- <Route path="*" element={<Dashboard />} />
101
- </Route>
102
- </Routes>
103
- </BrowserRouter>
104
- ```
105
-
106
- Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
107
-
108
- Another common issue arose in Data Routers (and Remix) where any `<Form>` should post to it's own route `action` if you the user doesn't specify a form action:
109
-
110
- ```jsx
111
- let router = createBrowserRouter({
112
- path: "/dashboard",
113
- children: [
114
- {
115
- path: "*",
116
- action: dashboardAction,
117
- Component() {
118
- // ❌ This form is broken! It throws a 405 error when it submits because
119
- // it tries to submit to /dashboard (without the splat value) and the parent
120
- // `/dashboard` route doesn't have an action
121
- return <Form method="post">...</Form>;
122
- },
123
- },
124
- ],
125
- });
126
- ```
127
-
128
- This is just a compounded issue from the above because the default location for a `Form` to submit to is itself (`"."`) - and if we ignore the splat portion, that now resolves to the parent route.
129
-
130
- **The Solution**
131
- If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage `../` for any links to "sibling" pages:
132
-
133
- ```jsx
134
- <BrowserRouter>
135
- <Routes>
136
- <Route path="dashboard">
137
- <Route index path="*" element={<Dashboard />} />
138
- </Route>
139
- </Routes>
140
- </BrowserRouter>
141
-
142
- function Dashboard() {
143
- return (
144
- <div>
145
- <h2>Dashboard</h2>
146
- <nav>
147
- <Link to="..">Dashboard Home</Link>
148
- <Link to="../team">Team</Link>
149
- <Link to="../projects">Projects</Link>
150
- </nav>
151
-
152
- <Routes>
153
- <Route path="/" element={<DashboardHome />} />
154
- <Route path="team" element={<DashboardTeam />} />
155
- <Route path="projects" element={<DashboardProjects />} />
156
- </Router>
157
- </div>
158
- );
159
- }
160
- ```
161
-
162
- This way, `.` means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and `..` always means "my parents pathname".
163
-
164
- ### Patch Changes
165
-
166
- - Updated dependencies:
167
- - `@remix-run/router@1.14.0`
168
- - `react-router@6.21.0`
169
-
170
3
  ## 6.20.1
171
4
 
172
5
  ### Patch Changes
173
6
 
174
- - Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
7
+ - Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
175
8
  - Updated dependencies:
176
9
  - `react-router@6.20.1`
177
10
  - `@remix-run/router@1.13.1`
@@ -426,7 +259,7 @@
426
259
 
427
260
  ## 6.12.1
428
261
 
429
- > \[!WARNING]
262
+ > [!WARNING]
430
263
  > Please use version `6.13.0` or later instead of `6.12.1`. This version suffers from a `webpack`/`terser` minification issue resulting in invalid minified code in your resulting production bundles which can cause issues in your application. See [#10579](https://github.com/remix-run/react-router/issues/10579) for more details.
431
264
 
432
265
  ### Patch Changes
@@ -761,7 +594,7 @@
761
594
 
762
595
  ## 6.4.0
763
596
 
764
- 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).
597
+ 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][rr-docs], especially the [feature overview][rr-feature-overview] and the [tutorial][rr-tutorial].
765
598
 
766
599
  **New APIs**
767
600
 
@@ -787,3 +620,7 @@ Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs ov
787
620
  **Updated Dependencies**
788
621
 
789
622
  - `react-router@6.4.0`
623
+
624
+ [rr-docs]: https://reactrouter.com
625
+ [rr-feature-overview]: https://reactrouter.com/start/overview
626
+ [rr-tutorial]: https://reactrouter.com/start/tutorial
package/dist/index.d.ts CHANGED
@@ -4,12 +4,13 @@
4
4
  */
5
5
  import * as React from "react";
6
6
  import type { FutureConfig, Location, NavigateOptions, RelativeRoutingType, RouteObject, RouterProviderProps, To } from "react-router";
7
- import type { Fetcher, FormEncType, FormMethod, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod, BlockerFunction } from "@remix-run/router";
7
+ import type { DataResult, DataStrategyFunction, DataStrategyFunctionArgs, Fetcher, FormEncType, FormMethod, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod, BlockerFunction } from "@remix-run/router";
8
+ import { ResultType, UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@remix-run/router";
8
9
  import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit, SubmitTarget } from "./dom";
9
10
  import { createSearchParams } from "./dom";
10
- export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
11
- export { createSearchParams };
12
- export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker, BlockerFunction, DataRouteMatch, DataRouteObject, ErrorResponse, Fetcher, FutureConfig, 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";
11
+ export type { DataResult, DataStrategyFunction, DataStrategyFunctionArgs, FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
12
+ export { createSearchParams, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, ResultType, };
13
+ export type { ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, ErrorResponse, Fetcher, FutureConfig, 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
14
  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
15
  /** @internal */
15
16
  export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, } from "react-router";
@@ -24,6 +25,7 @@ interface DOMRouterOpts {
24
25
  future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
25
26
  hydrationData?: HydrationState;
26
27
  window?: Window;
28
+ unstable_dataStrategy?: DataStrategyFunction;
27
29
  }
28
30
  export declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
29
31
  export declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v0.0.0-experimental-c9f8a7b2
2
+ * React Router DOM v0.0.0-experimental-e960cf1a
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -13,6 +13,7 @@ import * as ReactDOM from 'react-dom';
13
13
  import { UNSAFE_mapRouteProperties, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, Router, UNSAFE_useRoutesImpl, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, useBlocker } from 'react-router';
14
14
  export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, 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, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router';
15
15
  import { stripBasename, UNSAFE_warning, createRouter, createBrowserHistory, createHashHistory, UNSAFE_ErrorResponseImpl, UNSAFE_invariant, joinPaths, IDLE_FETCHER, matchPath } from '@remix-run/router';
16
+ export { ResultType, UNSAFE_ErrorResponseImpl } from '@remix-run/router';
16
17
 
17
18
  function _extends() {
18
19
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -222,7 +223,8 @@ function createBrowserRouter(routes, opts) {
222
223
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
223
224
  routes,
224
225
  mapRouteProperties: UNSAFE_mapRouteProperties,
225
- window: opts == null ? void 0 : opts.window
226
+ window: opts == null ? void 0 : opts.window,
227
+ unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy
226
228
  }).initialize();
227
229
  }
228
230
  function createHashRouter(routes, opts) {
@@ -328,8 +330,6 @@ const START_TRANSITION = "startTransition";
328
330
  const startTransitionImpl = React[START_TRANSITION];
329
331
  const FLUSH_SYNC = "flushSync";
330
332
  const flushSyncImpl = ReactDOM[FLUSH_SYNC];
331
- const USE_ID = "useId";
332
- const useIdImpl = React[USE_ID];
333
333
  function startTransitionSafe(cb) {
334
334
  if (startTransitionImpl) {
335
335
  startTransitionImpl(cb);
@@ -524,7 +524,7 @@ function RouterProvider(_ref) {
524
524
  }
525
525
  }, [vtContext.isTransitioning, interruption]);
526
526
  React.useEffect(() => {
527
- process.env.NODE_ENV !== "production" ? UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") : void 0;
527
+ process.env.NODE_ENV !== "production" ? UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`") : void 0;
528
528
  // Only log this once on initial mount
529
529
  // eslint-disable-next-line react-hooks/exhaustive-deps
530
530
  }, []);
@@ -549,7 +549,10 @@ function RouterProvider(_ref) {
549
549
  router,
550
550
  navigator,
551
551
  static: false,
552
- basename
552
+ basename,
553
+ future: {
554
+ v7_relativeSplatPath: router.future.v7_relativeSplatPath
555
+ }
553
556
  }), [router, navigator, basename]);
554
557
  // The fragment and {null} here are important! We need them to keep React 18's
555
558
  // useId happy when we are server-rendering since we may have a <script> here
@@ -569,11 +572,8 @@ function RouterProvider(_ref) {
569
572
  basename: basename,
570
573
  location: state.location,
571
574
  navigationType: state.historyAction,
572
- navigator: navigator,
573
- future: {
574
- v7_relativeSplatPath: router.future.v7_relativeSplatPath
575
- }
576
- }, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, {
575
+ navigator: navigator
576
+ }, state.initialized ? /*#__PURE__*/React.createElement(DataRoutes, {
577
577
  routes: router.routes,
578
578
  future: router.future,
579
579
  state: state
@@ -798,8 +798,7 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
798
798
  let location = useLocation();
799
799
  let routerState = React.useContext(UNSAFE_DataRouterStateContext);
800
800
  let {
801
- navigator,
802
- basename
801
+ navigator
803
802
  } = React.useContext(UNSAFE_NavigationContext);
804
803
  let isTransitioning = routerState != null &&
805
804
  // Conditional usage is OK here because the usage of a data router is static
@@ -813,9 +812,6 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
813
812
  nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
814
813
  toPathname = toPathname.toLowerCase();
815
814
  }
816
- if (nextLocationPathname && basename) {
817
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
818
- }
819
815
  // If the `to` has a trailing slash, look at that exact spot. Otherwise,
820
816
  // we're looking for a slash _after_ what's in `to`. For example:
821
817
  //
@@ -1139,14 +1135,10 @@ function useFetcher(_temp3) {
1139
1135
  !route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFetcher must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0;
1140
1136
  !(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;
1141
1137
  // Fetcher key handling
1142
- // OK to call conditionally to feature detect `useId`
1143
- // eslint-disable-next-line react-hooks/rules-of-hooks
1144
- let defaultKey = useIdImpl ? useIdImpl() : "";
1145
- let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
1138
+ let [fetcherKey, setFetcherKey] = React.useState(key || "");
1146
1139
  if (key && key !== fetcherKey) {
1147
1140
  setFetcherKey(key);
1148
1141
  } else if (!fetcherKey) {
1149
- // We will only fall through here when `useId` is not available
1150
1142
  setFetcherKey(getUniqueFetcherId());
1151
1143
  }
1152
1144
  // Registration/cleanup