react-router-dom 6.21.1 → 6.21.2-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,14 @@
1
1
  # `react-router-dom`
2
2
 
3
+ ## 6.21.2-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Leverage `useId` for internal fetcher keys when available ([#11166](https://github.com/remix-run/react-router/pull/11166))
8
+ - Updated dependencies:
9
+ - `@remix-run/router@1.14.2-pre.0`
10
+ - `react-router@6.21.2-pre.0`
11
+
3
12
  ## 6.21.1
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v6.21.1
2
+ * React Router DOM v6.21.2-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -328,6 +328,8 @@ const START_TRANSITION = "startTransition";
328
328
  const startTransitionImpl = React[START_TRANSITION];
329
329
  const FLUSH_SYNC = "flushSync";
330
330
  const flushSyncImpl = ReactDOM[FLUSH_SYNC];
331
+ const USE_ID = "useId";
332
+ const useIdImpl = React[USE_ID];
331
333
  function startTransitionSafe(cb) {
332
334
  if (startTransitionImpl) {
333
335
  startTransitionImpl(cb);
@@ -1133,10 +1135,14 @@ function useFetcher(_temp3) {
1133
1135
  !route ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "useFetcher must be used inside a RouteContext") : UNSAFE_invariant(false) : void 0;
1134
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;
1135
1137
  // Fetcher key handling
1136
- let [fetcherKey, setFetcherKey] = React.useState(key || "");
1138
+ // OK to call conditionally to feature detect `useId`
1139
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1140
+ let defaultKey = useIdImpl ? useIdImpl() : "";
1141
+ let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
1137
1142
  if (key && key !== fetcherKey) {
1138
1143
  setFetcherKey(key);
1139
1144
  } else if (!fetcherKey) {
1145
+ // We will only fall through here when `useId` is not available
1140
1146
  setFetcherKey(getUniqueFetcherId());
1141
1147
  }
1142
1148
  // Registration/cleanup