react-router 0.0.0-experimental-add6f8aa → 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,172 +1,10 @@
1
1
  # `react-router`
2
2
 
3
- ## 6.21.3
4
-
5
- ### Patch Changes
6
-
7
- - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
8
-
9
- ## 6.21.2
10
-
11
- ### Patch Changes
12
-
13
- - Updated dependencies:
14
- - `@remix-run/router@1.14.2`
15
-
16
- ## 6.21.1
17
-
18
- ### Patch Changes
19
-
20
- - Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
21
- - Updated dependencies:
22
- - `@remix-run/router@1.14.1`
23
-
24
- ## 6.21.0
25
-
26
- ### Minor Changes
27
-
28
- - 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))
29
-
30
- 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))
31
-
32
- **The Bug**
33
- 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.
34
-
35
- **The Background**
36
- 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:
37
-
38
- ```jsx
39
- <BrowserRouter>
40
- <Routes>
41
- <Route path="/" element={<Home />} />
42
- <Route path="dashboard/*" element={<Dashboard />} />
43
- </Routes>
44
- </BrowserRouter>
45
- ```
46
-
47
- Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
48
-
49
- ```jsx
50
- function Dashboard() {
51
- return (
52
- <div>
53
- <h2>Dashboard</h2>
54
- <nav>
55
- <Link to="/">Dashboard Home</Link>
56
- <Link to="team">Team</Link>
57
- <Link to="projects">Projects</Link>
58
- </nav>
59
-
60
- <Routes>
61
- <Route path="/" element={<DashboardHome />} />
62
- <Route path="team" element={<DashboardTeam />} />
63
- <Route path="projects" element={<DashboardProjects />} />
64
- </Routes>
65
- </div>
66
- );
67
- }
68
- ```
69
-
70
- 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.
71
-
72
- **The Problem**
73
-
74
- 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 `"."`:
75
-
76
- ```jsx
77
- // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
78
- function DashboardTeam() {
79
- // ❌ This is broken and results in <a href="/dashboard">
80
- return <Link to=".">A broken link to the Current URL</Link>;
81
-
82
- // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
83
- return <Link to="./team">A broken link to the Current URL</Link>;
84
- }
85
- ```
86
-
87
- 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.
88
-
89
- Even worse, consider a nested splat route configuration:
90
-
91
- ```jsx
92
- <BrowserRouter>
93
- <Routes>
94
- <Route path="dashboard">
95
- <Route path="*" element={<Dashboard />} />
96
- </Route>
97
- </Routes>
98
- </BrowserRouter>
99
- ```
100
-
101
- Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
102
-
103
- 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:
104
-
105
- ```jsx
106
- let router = createBrowserRouter({
107
- path: "/dashboard",
108
- children: [
109
- {
110
- path: "*",
111
- action: dashboardAction,
112
- Component() {
113
- // ❌ This form is broken! It throws a 405 error when it submits because
114
- // it tries to submit to /dashboard (without the splat value) and the parent
115
- // `/dashboard` route doesn't have an action
116
- return <Form method="post">...</Form>;
117
- },
118
- },
119
- ],
120
- });
121
- ```
122
-
123
- 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.
124
-
125
- **The Solution**
126
- 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:
127
-
128
- ```jsx
129
- <BrowserRouter>
130
- <Routes>
131
- <Route path="dashboard">
132
- <Route index path="*" element={<Dashboard />} />
133
- </Route>
134
- </Routes>
135
- </BrowserRouter>
136
-
137
- function Dashboard() {
138
- return (
139
- <div>
140
- <h2>Dashboard</h2>
141
- <nav>
142
- <Link to="..">Dashboard Home</Link>
143
- <Link to="../team">Team</Link>
144
- <Link to="../projects">Projects</Link>
145
- </nav>
146
-
147
- <Routes>
148
- <Route path="/" element={<DashboardHome />} />
149
- <Route path="team" element={<DashboardTeam />} />
150
- <Route path="projects" element={<DashboardProjects />} />
151
- </Router>
152
- </div>
153
- );
154
- }
155
- ```
156
-
157
- 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".
158
-
159
- ### Patch Changes
160
-
161
- - Properly handle falsy error values in ErrorBoundary's ([#11071](https://github.com/remix-run/react-router/pull/11071))
162
- - Updated dependencies:
163
- - `@remix-run/router@1.14.0`
164
-
165
3
  ## 6.20.1
166
4
 
167
5
  ### Patch Changes
168
6
 
169
- - 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))
170
8
  - Updated dependencies:
171
9
  - `@remix-run/router@1.13.1`
172
10
 
@@ -194,7 +32,6 @@
194
32
  ### Patch Changes
195
33
 
196
34
  - Fix `useActionData` so it returns proper contextual action data and not _any_ action data in the tree ([#11023](https://github.com/remix-run/react-router/pull/11023))
197
-
198
35
  - Fix bug in `useResolvedPath` that would cause `useResolvedPath(".")` in a splat route to lose the splat portion of the URL path. ([#10983](https://github.com/remix-run/react-router/pull/10983))
199
36
 
200
37
  - ⚠️ This fixes a quite long-standing bug specifically for `"."` paths inside a splat route which incorrectly dropped the splat portion of the URL. If you are relative routing via `"."` inside a splat route in your application you should double check that your logic is not relying on this buggy behavior and update accordingly.
@@ -307,7 +144,7 @@
307
144
 
308
145
  ## 6.12.1
309
146
 
310
- > \[!WARNING]
147
+ > [!WARNING]
311
148
  > 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.
312
149
 
313
150
  ### Patch Changes
@@ -639,7 +476,7 @@ function Comp() {
639
476
 
640
477
  ## 6.4.0
641
478
 
642
- 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).
479
+ 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].
643
480
 
644
481
  **New APIs**
645
482
 
@@ -657,3 +494,7 @@ Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs ov
657
494
  **Updated Dependencies**
658
495
 
659
496
  - `@remix-run/router@1.0.0`
497
+
498
+ [rr-docs]: https://reactrouter.com
499
+ [rr-feature-overview]: https://reactrouter.com/start/overview
500
+ [rr-tutorial]: https://reactrouter.com/start/tutorial
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, ErrorResponse, Fetcher, HydrationState, InitialEntry, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, RedirectFunction, RelativeRoutingType, Router as RemixRouter, FutureConfig as RouterFutureConfig, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch } from "@remix-run/router";
1
+ import type { ActionFunction, ActionFunctionArgs, Blocker, BlockerFunction, DataStrategyFunction, ErrorResponse, Fetcher, HydrationState, InitialEntry, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, Navigation, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, RedirectFunction, RelativeRoutingType, Router as RemixRouter, FutureConfig as RouterFutureConfig, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch } from "@remix-run/router";
2
2
  import { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, resolvePath } from "@remix-run/router";
3
3
  import type { AwaitProps, FutureConfig, IndexRouteProps, LayoutRouteProps, MemoryRouterProps, NavigateProps, OutletProps, PathRouteProps, RouteProps, RouterProps, RouterProviderProps, RoutesProps } from "./lib/components";
4
4
  import { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, createRoutesFromChildren, renderMatches } from "./lib/components";
@@ -9,7 +9,7 @@ import { useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useIn
9
9
  type Hash = string;
10
10
  type Pathname = string;
11
11
  type Search = string;
12
- export type { ActionFunction, ActionFunctionArgs, AwaitProps, DataRouteMatch, DataRouteObject, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, PathRouteProps, Pathname, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, Blocker, BlockerFunction, };
12
+ export type { ActionFunction, ActionFunctionArgs, AwaitProps, DataRouteMatch, DataRouteObject, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, ParamParseKey, Params, Path, PathMatch, PathParam, PathPattern, PathRouteProps, Pathname, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, Blocker as unstable_Blocker, BlockerFunction as unstable_BlockerFunction, };
13
13
  export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createPath, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
14
14
  declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
15
15
  hasErrorBoundary: boolean;
@@ -20,6 +20,7 @@ export declare function createMemoryRouter(routes: RouteObject[], opts?: {
20
20
  hydrationData?: HydrationState;
21
21
  initialEntries?: InitialEntry[];
22
22
  initialIndex?: number;
23
+ unstable_dataStrategy?: DataStrategyFunction;
23
24
  }): RemixRouter;
24
25
  /** @internal */
25
26
  export { 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, };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-add6f8aa
2
+ * React Router v0.0.0-experimental-e960cf1a
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -378,7 +378,7 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
378
378
  });
379
379
  if (process.env.NODE_ENV !== "production") {
380
380
  process.env.NODE_ENV !== "production" ? UNSAFE_warning(parentRoute || matches != null, "No routes matched location \"" + location.pathname + location.search + location.hash + "\" ") : void 0;
381
- process.env.NODE_ENV !== "production" ? UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined || matches[matches.length - 1].route.lazy !== undefined, "Matched leaf route at location \"" + location.pathname + location.search + location.hash + "\" " + "does not have an element or Component. This means it will render an <Outlet /> with a " + "null value by default resulting in an \"empty\" page.") : void 0;
381
+ process.env.NODE_ENV !== "production" ? UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined, "Matched leaf route at location \"" + location.pathname + location.search + location.hash + "\" " + "does not have an element or Component. This means it will render an <Outlet /> with a " + "null value by default resulting in an \"empty\" page.") : void 0;
382
382
  }
383
383
  let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
384
384
  params: Object.assign({}, parentParams, match.params),
@@ -552,24 +552,17 @@ function _renderMatches(matches, parentMatches, dataRouterState, future) {
552
552
  if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
553
553
  fallbackIndex = i;
554
554
  }
555
- if (match.route.id) {
556
- let {
557
- loaderData,
558
- errors
559
- } = dataRouterState;
560
- let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!errors || errors[match.route.id] === undefined);
561
- if (match.route.lazy || needsToRunLoader) {
562
- // We found the first route that's not ready to render (waiting on
563
- // lazy, or has a loader that hasn't run yet). Flag that we need to
564
- // render a fallback and render up until the appropriate fallback
565
- renderFallback = true;
566
- if (fallbackIndex >= 0) {
567
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
568
- } else {
569
- renderedMatches = [renderedMatches[0]];
570
- }
571
- break;
555
+ if (match.route.loader && match.route.id && dataRouterState.loaderData[match.route.id] === undefined && (!dataRouterState.errors || dataRouterState.errors[match.route.id] === undefined)) {
556
+ // We found the first route without data/errors which means it's loader
557
+ // still needs to run. Flag that we need to render a fallback and
558
+ // render up until the appropriate fallback
559
+ renderFallback = true;
560
+ if (fallbackIndex >= 0) {
561
+ renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
562
+ } else {
563
+ renderedMatches = [renderedMatches[0]];
572
564
  }
565
+ break;
573
566
  }
574
567
  }
575
568
  }
@@ -947,7 +940,7 @@ function RouterProvider(_ref) {
947
940
  // pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
948
941
  React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
949
942
  React.useEffect(() => {
950
- 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;
943
+ process.env.NODE_ENV !== "production" ? UNSAFE_warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`") : void 0;
951
944
  // Only log this once on initial mount
952
945
  // eslint-disable-next-line react-hooks/exhaustive-deps
953
946
  }, []);
@@ -972,7 +965,10 @@ function RouterProvider(_ref) {
972
965
  router,
973
966
  navigator,
974
967
  static: false,
975
- basename
968
+ basename,
969
+ future: {
970
+ v7_relativeSplatPath: router.future.v7_relativeSplatPath
971
+ }
976
972
  }), [router, navigator, basename]);
977
973
 
978
974
  // The fragment and {null} here are important! We need them to keep React 18's
@@ -989,11 +985,8 @@ function RouterProvider(_ref) {
989
985
  basename: basename,
990
986
  location: state.location,
991
987
  navigationType: state.historyAction,
992
- navigator: navigator,
993
- future: {
994
- v7_relativeSplatPath: router.future.v7_relativeSplatPath
995
- }
996
- }, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, {
988
+ navigator: navigator
989
+ }, state.initialized ? /*#__PURE__*/React.createElement(DataRoutes, {
997
990
  routes: router.routes,
998
991
  future: router.future,
999
992
  state: state
@@ -1427,7 +1420,8 @@ function createMemoryRouter(routes, opts) {
1427
1420
  }),
1428
1421
  hydrationData: opts == null ? void 0 : opts.hydrationData,
1429
1422
  routes,
1430
- mapRouteProperties
1423
+ mapRouteProperties,
1424
+ unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy
1431
1425
  }).initialize();
1432
1426
  }
1433
1427