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

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,10 +1,177 @@
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
+
3
170
  ## 6.20.1
4
171
 
5
172
  ### Patch Changes
6
173
 
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))
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))
8
175
  - Updated dependencies:
9
176
  - `react-router@6.20.1`
10
177
  - `@remix-run/router@1.13.1`
@@ -259,7 +426,7 @@
259
426
 
260
427
  ## 6.12.1
261
428
 
262
- > [!WARNING]
429
+ > \[!WARNING]
263
430
  > 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.
264
431
 
265
432
  ### Patch Changes
@@ -594,7 +761,7 @@
594
761
 
595
762
  ## 6.4.0
596
763
 
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].
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).
598
765
 
599
766
  **New APIs**
600
767
 
@@ -620,7 +787,3 @@ Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs ov
620
787
  **Updated Dependencies**
621
788
 
622
789
  - `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,18 +4,19 @@
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 { 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";
7
+ import type { DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, Fetcher, FormEncType, FormMethod, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod, BlockerFunction } from "@remix-run/router";
8
+ import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@remix-run/router";
9
9
  import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit, SubmitTarget } from "./dom";
10
10
  import { createSearchParams } from "./dom";
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";
11
+ export type { DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
12
+ export { createSearchParams, ErrorResponseImpl as UNSAFE_ErrorResponseImpl };
13
+ 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";
14
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";
15
15
  /** @internal */
16
16
  export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, } from "react-router";
17
17
  declare global {
18
18
  var __staticRouterHydrationData: HydrationState | undefined;
19
+ var __reactRouterVersion: string;
19
20
  interface Document {
20
21
  startViewTransition(cb: () => Promise<void> | void): ViewTransition;
21
22
  }
@@ -24,8 +25,8 @@ interface DOMRouterOpts {
24
25
  basename?: string;
25
26
  future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
26
27
  hydrationData?: HydrationState;
27
- window?: Window;
28
28
  unstable_dataStrategy?: DataStrategyFunction;
29
+ window?: Window;
29
30
  }
30
31
  export declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
31
32
  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-e960cf1a
2
+ * React Router DOM v0.0.0-experimental-bc2c864b
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -13,7 +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
+ export { UNSAFE_ErrorResponseImpl } from '@remix-run/router';
17
17
 
18
18
  function _extends() {
19
19
  _extends = Object.assign ? Object.assign.bind() : function (target) {
@@ -211,6 +211,21 @@ function getFormSubmissionInfo(target, basename) {
211
211
  const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_viewTransition"],
212
212
  _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "unstable_viewTransition", "children"],
213
213
  _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_viewTransition"];
214
+ // HEY YOU! DON'T TOUCH THIS VARIABLE!
215
+ //
216
+ // It is replaced with the proper version at build time via a babel plugin in
217
+ // the rollup config.
218
+ //
219
+ // Export a global property onto the window for React Router detection by the
220
+ // Core Web Vitals Technology Report. This way they can configure the `wappalyzer`
221
+ // to detect and properly classify live websites as being built with React Router:
222
+ // https://github.com/HTTPArchive/wappalyzer/blob/main/src/technologies/r.json
223
+ const REACT_ROUTER_VERSION = "0";
224
+ try {
225
+ window.__reactRouterVersion = REACT_ROUTER_VERSION;
226
+ } catch (e) {
227
+ // no-op
228
+ }
214
229
  function createBrowserRouter(routes, opts) {
215
230
  return createRouter({
216
231
  basename: opts == null ? void 0 : opts.basename,
@@ -223,8 +238,8 @@ function createBrowserRouter(routes, opts) {
223
238
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
224
239
  routes,
225
240
  mapRouteProperties: UNSAFE_mapRouteProperties,
226
- window: opts == null ? void 0 : opts.window,
227
- unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy
241
+ unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
242
+ window: opts == null ? void 0 : opts.window
228
243
  }).initialize();
229
244
  }
230
245
  function createHashRouter(routes, opts) {
@@ -239,6 +254,7 @@ function createHashRouter(routes, opts) {
239
254
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
240
255
  routes,
241
256
  mapRouteProperties: UNSAFE_mapRouteProperties,
257
+ unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
242
258
  window: opts == null ? void 0 : opts.window
243
259
  }).initialize();
244
260
  }
@@ -330,6 +346,8 @@ const START_TRANSITION = "startTransition";
330
346
  const startTransitionImpl = React[START_TRANSITION];
331
347
  const FLUSH_SYNC = "flushSync";
332
348
  const flushSyncImpl = ReactDOM[FLUSH_SYNC];
349
+ const USE_ID = "useId";
350
+ const useIdImpl = React[USE_ID];
333
351
  function startTransitionSafe(cb) {
334
352
  if (startTransitionImpl) {
335
353
  startTransitionImpl(cb);
@@ -524,7 +542,7 @@ function RouterProvider(_ref) {
524
542
  }
525
543
  }, [vtContext.isTransitioning, interruption]);
526
544
  React.useEffect(() => {
527
- process.env.NODE_ENV !== "production" ? UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`") : void 0;
545
+ 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;
528
546
  // Only log this once on initial mount
529
547
  // eslint-disable-next-line react-hooks/exhaustive-deps
530
548
  }, []);
@@ -549,10 +567,7 @@ function RouterProvider(_ref) {
549
567
  router,
550
568
  navigator,
551
569
  static: false,
552
- basename,
553
- future: {
554
- v7_relativeSplatPath: router.future.v7_relativeSplatPath
555
- }
570
+ basename
556
571
  }), [router, navigator, basename]);
557
572
  // The fragment and {null} here are important! We need them to keep React 18's
558
573
  // useId happy when we are server-rendering since we may have a <script> here
@@ -572,8 +587,11 @@ function RouterProvider(_ref) {
572
587
  basename: basename,
573
588
  location: state.location,
574
589
  navigationType: state.historyAction,
575
- navigator: navigator
576
- }, state.initialized ? /*#__PURE__*/React.createElement(DataRoutes, {
590
+ navigator: navigator,
591
+ future: {
592
+ v7_relativeSplatPath: router.future.v7_relativeSplatPath
593
+ }
594
+ }, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, {
577
595
  routes: router.routes,
578
596
  future: router.future,
579
597
  state: state
@@ -798,7 +816,8 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
798
816
  let location = useLocation();
799
817
  let routerState = React.useContext(UNSAFE_DataRouterStateContext);
800
818
  let {
801
- navigator
819
+ navigator,
820
+ basename
802
821
  } = React.useContext(UNSAFE_NavigationContext);
803
822
  let isTransitioning = routerState != null &&
804
823
  // Conditional usage is OK here because the usage of a data router is static
@@ -812,6 +831,9 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
812
831
  nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
813
832
  toPathname = toPathname.toLowerCase();
814
833
  }
834
+ if (nextLocationPathname && basename) {
835
+ nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
836
+ }
815
837
  // If the `to` has a trailing slash, look at that exact spot. Otherwise,
816
838
  // we're looking for a slash _after_ what's in `to`. For example:
817
839
  //
@@ -1135,10 +1157,14 @@ function useFetcher(_temp3) {
1135
1157
  !route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFetcher must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0;
1136
1158
  !(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;
1137
1159
  // Fetcher key handling
1138
- let [fetcherKey, setFetcherKey] = React.useState(key || "");
1160
+ // OK to call conditionally to feature detect `useId`
1161
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1162
+ let defaultKey = useIdImpl ? useIdImpl() : "";
1163
+ let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
1139
1164
  if (key && key !== fetcherKey) {
1140
1165
  setFetcherKey(key);
1141
1166
  } else if (!fetcherKey) {
1167
+ // We will only fall through here when `useId` is not available
1142
1168
  setFetcherKey(getUniqueFetcherId());
1143
1169
  }
1144
1170
  // Registration/cleanup