react-router 6.6.1 → 6.6.2

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,17 @@
1
1
  # `react-router`
2
2
 
3
+ ## 6.6.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
8
+
9
+ ## 6.6.2-pre.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
14
+
3
15
  ## 6.6.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { AbortedDeferredError, Action as NavigationType, createPath, defer, gene
3
3
  import type { AwaitProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps, RouterProviderProps } from "./lib/components";
4
4
  import { enhanceManualRouteObjects, createRoutesFromChildren, renderMatches, Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes } from "./lib/components";
5
5
  import type { DataRouteMatch, DataRouteObject, IndexRouteObject, Navigator, NavigateOptions, NonIndexRouteObject, RouteMatch, RouteObject, RelativeRoutingType } from "./lib/context";
6
- import { DataRouterContext, DataRouterStateContext, DataStaticRouterContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
6
+ import { DataRouterContext, DataRouterStateContext, LocationContext, NavigationContext, RouteContext } from "./lib/context";
7
7
  import type { NavigateFunction } from "./lib/hooks";
8
8
  import { useHref, useInRouterContext, useLocation, useMatch, useNavigationType, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useActionData, useAsyncError, useAsyncValue, useLoaderData, useMatches, useNavigation, useRevalidator, useRouteError, useRouteLoaderData } from "./lib/hooks";
9
9
  declare type Hash = string;
@@ -18,4 +18,4 @@ export declare function createMemoryRouter(routes: RouteObject[], opts?: {
18
18
  initialIndex?: number;
19
19
  }): RemixRouter;
20
20
  /** @internal */
21
- export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, };
21
+ export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.6.1
2
+ * React Router v6.6.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -207,13 +207,6 @@ const isServerEnvironment = !canUseDOM;
207
207
  const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
208
208
  const useSyncExternalStore = "useSyncExternalStore" in React ? (module => module.useSyncExternalStore)(React) : shim;
209
209
 
210
- // Contexts for data routers
211
- const DataStaticRouterContext = /*#__PURE__*/React.createContext(null);
212
-
213
- if (process.env.NODE_ENV !== "production") {
214
- DataStaticRouterContext.displayName = "DataStaticRouterContext";
215
- }
216
-
217
210
  const DataRouterContext = /*#__PURE__*/React.createContext(null);
218
211
 
219
212
  if (process.env.NODE_ENV !== "production") {
@@ -660,11 +653,11 @@ function RenderedRoute(_ref) {
660
653
  match,
661
654
  children
662
655
  } = _ref;
663
- let dataStaticRouterContext = React.useContext(DataStaticRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
656
+ let dataRouterContext = React.useContext(DataRouterContext); // Track how deep we got in our render pass to emulate SSR componentDidCatch
664
657
  // in a DataStaticRouter
665
658
 
666
- if (dataStaticRouterContext && match.route.errorElement) {
667
- dataStaticRouterContext._deepestRenderedBoundaryId = match.route.id;
659
+ if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && match.route.errorElement) {
660
+ dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
668
661
  }
669
662
 
670
663
  return /*#__PURE__*/React.createElement(RouteContext.Provider, {
@@ -930,8 +923,14 @@ function RouterProvider(_ref) {
930
923
  })
931
924
  };
932
925
  }, [router]);
933
- let basename = router.basename || "/";
934
- return /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
926
+ let basename = router.basename || "/"; // The fragment and {null} here are important! We need them to keep React 18's
927
+ // useId happy when we are server-rendering since we may have a <script> here
928
+ // containing the hydrated server-side staticContext (from StaticRouterProvider).
929
+ // useId relies on the component tree structure to generate deterministic id's
930
+ // so we need to ensure it remains the same on the client even though
931
+ // we don't need the <script> tag
932
+
933
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataRouterContext.Provider, {
935
934
  value: {
936
935
  router,
937
936
  navigator,
@@ -946,7 +945,7 @@ function RouterProvider(_ref) {
946
945
  location: router.state.location,
947
946
  navigationType: router.state.historyAction,
948
947
  navigator: navigator
949
- }, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement)));
948
+ }, router.state.initialized ? /*#__PURE__*/React.createElement(Routes, null) : fallbackElement))), null);
950
949
  }
951
950
 
952
951
  /**
@@ -1370,5 +1369,5 @@ function createMemoryRouter(routes, opts) {
1370
1369
  }).initialize();
1371
1370
  } ///////////////////////////////////////////////////////////////////////////////
1372
1371
 
1373
- export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, DataStaticRouterContext as UNSAFE_DataStaticRouterContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1372
+ 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, enhanceManualRouteObjects as UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
1374
1373
  //# sourceMappingURL=index.js.map