@remix-run/router 0.0.0-experimental-e960cf1a → 0.0.0-experimental-a0888892

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,218 @@
1
1
  # `@remix-run/router`
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add a `createStaticHandler` `future.v7_throwAbortReason` flag to throw `request.signal.reason` (defaults to a `DOMException`) when a request is aborted instead of an `Error` such as `new Error("query() call aborted: GET /path")` ([#11104](https://github.com/remix-run/react-router/pull/11104))
8
+
9
+ - Please note that `DOMException` was added in Node v17 so you will not get a `DOMException` on Node 16 and below.
10
+
11
+ ### Patch Changes
12
+
13
+ - Respect the `ErrorResponse` status code if passed to `getStaticContextFormError` ([#11213](https://github.com/remix-run/react-router/pull/11213))
14
+
15
+ ## 1.14.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Fix bug where dashes were not picked up in dynamic parameter names ([#11160](https://github.com/remix-run/react-router/pull/11160))
20
+ - Do not attempt to deserialize empty JSON responses ([#11164](https://github.com/remix-run/react-router/pull/11164))
21
+
22
+ ## 1.14.1
23
+
24
+ ### Patch Changes
25
+
26
+ - 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))
27
+ - Fix bug preventing revalidation from occurring for persisted fetchers unmounted during the `submitting` phase ([#11102](https://github.com/remix-run/react-router/pull/11102))
28
+ - De-dup relative path logic in `resolveTo` ([#11097](https://github.com/remix-run/react-router/pull/11097))
29
+
30
+ ## 1.14.0
31
+
32
+ ### Minor Changes
33
+
34
+ - Added a new `future.v7_partialHydration` future flag that enables partial hydration of a data router when Server-Side Rendering. This allows you to provide `hydrationData.loaderData` that has values for _some_ initially matched route loaders, but not all. When this flag is enabled, the router will call `loader` functions for routes that do not have hydration loader data during `router.initialize()`, and it will render down to the deepest provided `HydrateFallback` (up to the first route without hydration data) while it executes the unhydrated routes. ([#11033](https://github.com/remix-run/react-router/pull/11033))
35
+
36
+ For example, the following router has a `root` and `index` route, but only provided `hydrationData.loaderData` for the `root` route. Because the `index` route has a `loader`, we need to run that during initialization. With `future.v7_partialHydration` specified, `<RouterProvider>` will render the `RootComponent` (because it has data) and then the `IndexFallback` (since it does not have data). Once `indexLoader` finishes, application will update and display `IndexComponent`.
37
+
38
+ ```jsx
39
+ let router = createBrowserRouter(
40
+ [
41
+ {
42
+ id: "root",
43
+ path: "/",
44
+ loader: rootLoader,
45
+ Component: RootComponent,
46
+ Fallback: RootFallback,
47
+ children: [
48
+ {
49
+ id: "index",
50
+ index: true,
51
+ loader: indexLoader,
52
+ Component: IndexComponent,
53
+ HydrateFallback: IndexFallback,
54
+ },
55
+ ],
56
+ },
57
+ ],
58
+ {
59
+ future: {
60
+ v7_partialHydration: true,
61
+ },
62
+ hydrationData: {
63
+ loaderData: {
64
+ root: { message: "Hydrated from Root!" },
65
+ },
66
+ },
67
+ }
68
+ );
69
+ ```
70
+
71
+ If the above example did not have an `IndexFallback`, then `RouterProvider` would instead render the `RootFallback` while it executed the `indexLoader`.
72
+
73
+ **Note:** When `future.v7_partialHydration` is provided, the `<RouterProvider fallbackElement>` prop is ignored since you can move it to a `Fallback` on your top-most route. The `fallbackElement` prop will be removed in React Router v7 when `v7_partialHydration` behavior becomes the standard behavior.
74
+
75
+ - 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))
76
+
77
+ 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))
78
+
79
+ **The Bug**
80
+ 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.
81
+
82
+ **The Background**
83
+ 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:
84
+
85
+ ```jsx
86
+ <BrowserRouter>
87
+ <Routes>
88
+ <Route path="/" element={<Home />} />
89
+ <Route path="dashboard/*" element={<Dashboard />} />
90
+ </Routes>
91
+ </BrowserRouter>
92
+ ```
93
+
94
+ Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
95
+
96
+ ```jsx
97
+ function Dashboard() {
98
+ return (
99
+ <div>
100
+ <h2>Dashboard</h2>
101
+ <nav>
102
+ <Link to="/">Dashboard Home</Link>
103
+ <Link to="team">Team</Link>
104
+ <Link to="projects">Projects</Link>
105
+ </nav>
106
+
107
+ <Routes>
108
+ <Route path="/" element={<DashboardHome />} />
109
+ <Route path="team" element={<DashboardTeam />} />
110
+ <Route path="projects" element={<DashboardProjects />} />
111
+ </Routes>
112
+ </div>
113
+ );
114
+ }
115
+ ```
116
+
117
+ 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.
118
+
119
+ **The Problem**
120
+
121
+ 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 `"."`:
122
+
123
+ ```jsx
124
+ // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
125
+ function DashboardTeam() {
126
+ // ❌ This is broken and results in <a href="/dashboard">
127
+ return <Link to=".">A broken link to the Current URL</Link>;
128
+
129
+ // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
130
+ return <Link to="./team">A broken link to the Current URL</Link>;
131
+ }
132
+ ```
133
+
134
+ 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.
135
+
136
+ Even worse, consider a nested splat route configuration:
137
+
138
+ ```jsx
139
+ <BrowserRouter>
140
+ <Routes>
141
+ <Route path="dashboard">
142
+ <Route path="*" element={<Dashboard />} />
143
+ </Route>
144
+ </Routes>
145
+ </BrowserRouter>
146
+ ```
147
+
148
+ Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
149
+
150
+ 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:
151
+
152
+ ```jsx
153
+ let router = createBrowserRouter({
154
+ path: "/dashboard",
155
+ children: [
156
+ {
157
+ path: "*",
158
+ action: dashboardAction,
159
+ Component() {
160
+ // ❌ This form is broken! It throws a 405 error when it submits because
161
+ // it tries to submit to /dashboard (without the splat value) and the parent
162
+ // `/dashboard` route doesn't have an action
163
+ return <Form method="post">...</Form>;
164
+ },
165
+ },
166
+ ],
167
+ });
168
+ ```
169
+
170
+ 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.
171
+
172
+ **The Solution**
173
+ 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:
174
+
175
+ ```jsx
176
+ <BrowserRouter>
177
+ <Routes>
178
+ <Route path="dashboard">
179
+ <Route index path="*" element={<Dashboard />} />
180
+ </Route>
181
+ </Routes>
182
+ </BrowserRouter>
183
+
184
+ function Dashboard() {
185
+ return (
186
+ <div>
187
+ <h2>Dashboard</h2>
188
+ <nav>
189
+ <Link to="..">Dashboard Home</Link>
190
+ <Link to="../team">Team</Link>
191
+ <Link to="../projects">Projects</Link>
192
+ </nav>
193
+
194
+ <Routes>
195
+ <Route path="/" element={<DashboardHome />} />
196
+ <Route path="team" element={<DashboardTeam />} />
197
+ <Route path="projects" element={<DashboardProjects />} />
198
+ </Router>
199
+ </div>
200
+ );
201
+ }
202
+ ```
203
+
204
+ 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".
205
+
206
+ ### Patch Changes
207
+
208
+ - Catch and bubble errors thrown when trying to unwrap responses from `loader`/`action` functions ([#11061](https://github.com/remix-run/react-router/pull/11061))
209
+ - Fix `relative="path"` issue when rendering `Link`/`NavLink` outside of matched routes ([#11062](https://github.com/remix-run/react-router/pull/11062))
210
+
3
211
  ## 1.13.1
4
212
 
5
213
  ### Patch Changes
6
214
 
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))
215
+ - 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
216
 
9
217
  ## 1.13.0
10
218
 
@@ -484,11 +692,6 @@ function Comp() {
484
692
 
485
693
  This is the first stable release of `@remix-run/router`, which provides all the underlying routing and data loading/mutation logic for `react-router`. You should _not_ be using this package directly unless you are authoring a routing library similar to `react-router`.
486
694
 
487
- For an overview of the features provided by `react-router`, we recommend you go check out the [docs][rr-docs], especially the [feature overview][rr-feature-overview] and the [tutorial][rr-tutorial].
488
-
489
- For an overview of the features provided by `@remix-run/router`, please check out the [`README`][remix-router-readme].
695
+ For an overview of the features provided by `react-router`, we recommend 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).
490
696
 
491
- [rr-docs]: https://reactrouter.com
492
- [rr-feature-overview]: https://reactrouter.com/start/overview
493
- [rr-tutorial]: https://reactrouter.com/start/tutorial
494
- [remix-router-readme]: https://github.com/remix-run/react-router/blob/main/packages/router/README.md
697
+ For an overview of the features provided by `@remix-run/router`, please check out the [`README`](./README.md).
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticDataStrategyMatch, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, DataResult, DataStrategyFunction, DataStrategyFunctionArgs, ErrorResponse, FormEncType, FormMethod, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, } from "./utils";
2
- export { AbortedDeferredError, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, resolvePath, resolveTo, ResultType, stripBasename, } from "./utils";
1
+ export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, ErrorResponse, FormEncType, FormMethod, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathParam, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, UIMatch, V7_FormMethod, } from "./utils";
2
+ export { AbortedDeferredError, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, resolvePath, resolveTo, stripBasename, } from "./utils";
3
3
  export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
4
4
  export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
5
5
  export * from "./router";