Skip to content

Commit ba99ec5

Browse files
committed
Merge branch 'main' into release-next
2 parents 8bb3ffd + cc4436c commit ba99ec5

File tree

11 files changed

+39
-21
lines changed

11 files changed

+39
-21
lines changed

contributors.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
- dokeet
6464
- Drishtantr
6565
- edwin177
66+
- eiffelwong1
6667
- ek9
6768
- ekaansharora
6869
- elanis
@@ -118,6 +119,7 @@
118119
- jrakotoharisoa
119120
- juanpprieto
120121
- kachun333
122+
- Kakamotobi
121123
- kantuni
122124
- kark
123125
- KAROTT7

docs/components/link.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ A relative `<Link to>` value (that does not begin with `/`) resolves relative to
6767

6868
## `relative`
6969

70-
By default, links are relative to the route hierarchy (`relative="route"`), so `..` will go up one `Route` level. Occasionally, you may find that you have matching URL patterns that do not make sense to be nested, and you'd prefer to use relative _path_ routing. You can opt into this behavior with `relative="path"`:
70+
By default, links are relative to the route hierarchy (`relative="route"`), so `..` will go up one `Route` level from the current contextual route. Occasionally, you may find that you have matching URL patterns that do not make sense to be nested, and you'd prefer to use relative _path_ routing from the current contextual route path. You can opt into this behavior with `relative="path"`:
7171

7272
```jsx
7373
// Contact and EditContact do not share additional UI layout
@@ -81,7 +81,8 @@ By default, links are relative to the route hierarchy (`relative="route"`), so `
8181

8282
function EditContact() {
8383
// Since Contact is not a parent of EditContact we need to go up one level
84-
// in the path, instead of one level in the Route hierarchy
84+
// in the current contextual route path, instead of one level in the Route
85+
// hierarchy
8586
return (
8687
<Link to=".." relative="path">
8788
Cancel

docs/hooks/use-resolved-path.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,23 @@ And then it gets worse if you define the splat route as a child:
6767
```
6868

6969
- Now, `useResolvedPath(".")` and `useResolvedPath("..")` resolve to the exact same path inside `<Dashboard />`
70-
- If you were using a Data Router and defined an `action` on the splat route, you'd get a 405 error on `<Form>` submissions because they (by default) submit to `"."` which would resolve to the parent `/dashboard` route which doesn't have an `action`.
70+
- If you were using a Data Router and defined an `action` on the splat route, you'd get a 405 error on `<Form>` submissions inside `<Dashboard>` because they (by default) submit to `"."` which would resolve to the parent `/dashboard` route which doesn't have an `action`.
7171

7272
### Behavior with the flag
7373

7474
When you enable the flag, this "bug" is fixed so that path resolution is consistent across all route types, and `useResolvedPath(".")` always resolves to the current pathname for the contextual route. This includes any dynamic param or splat param values.
7575

76-
If you want to navigate between "sibling" routes within a splat route, it is suggested you move your splat route to it's own child (`<Route path="*" element={<Dashboard />} />`) and use `useResolvedPath("../teams")` and `useResolvedPath("../projects")` parent-relative paths to navigate to sibling routes.
76+
If you want to navigate between "sibling" routes within a splat route, it is suggested you move your splat route to it's own child and use `useResolvedPath("../teams")` and `useResolvedPath("../projects")` parent-relative paths to navigate to sibling `/dashboard` routes. Note that here we also use `index` so that the URL `/dashboard` also renders the `<Dashboard>` component.
77+
78+
```jsx
79+
<BrowserRouter>
80+
<Routes>
81+
<Route path="/dashboard">
82+
<Route index path="*" element={<Dashboard />} />
83+
</Route>
84+
</Routes>
85+
</BrowserRouter>
86+
```
7787

7888
[navlink]: ../components/nav-link
7989
[resolvepath]: ../utils/resolve-path

docs/hooks/use-view-transition-state.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ Consider clicking on an image in a list that you need to expand into the hero im
3030

3131
```jsx
3232
function NavImage({ src, alt, id }) {
33-
let to = `/images/${idx}`;
34-
let vt = unstable_useViewTransitionState(href);
33+
const to = `/images/${id}`;
34+
const isTransitioning =
35+
unstable_useViewTransitionState(to);
3536
return (
3637
<Link to={to} unstable_viewTransition>
3738
<img
3839
src={src}
3940
alt={alt}
4041
style={{
41-
viewTransitionName: vt ? "image-expand" : "",
42+
viewTransitionName: isTransitioning
43+
? "image-expand"
44+
: "",
4245
}}
4346
/>
4447
</Link>

docs/route/error-element.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Put an `errorElement` at the top of your route tree and handle nearly every erro
4646

4747
<docs-warning>We recommend _always_ providing at least a root-level `errorElement` before shipping your application to production, because the UI of the default `errorElement` is ugly and not intended for end-user consumption.</docs-warning>
4848

49-
If you do not provide an `errorElement` in your route tree to handle a given error, errors will bubble up and be handled by a default `errorElement` which will print the error message and stack trace. Some folks have questioned why the stack trace shows up in production builds. Normally, you don't want to expose stack traces on your production sites for security reasons. However, this is more applicable to server-side errors (and Remix does indeed strip stack traces from server-side loader/action responses). In the case of client-side `react-router-dom` applications the code is already available in the browser anyway so any hiding is just security through obscurity. Furthermore, we would still want to expose the error in the console, so removing it from the UI display is still not hiding any information about the stack trace. Not showing it in the UI _and_ not logging it to to the console would mean that application developers have no information _at all_ about production bugs, which poses its own set of issues. So, again we recommend you always add a root level `errorElement` before deploying your site to production!
49+
If you do not provide an `errorElement` in your route tree to handle a given error, errors will bubble up and be handled by a default `errorElement` which will print the error message and stack trace. Some folks have questioned why the stack trace shows up in production builds. Normally, you don't want to expose stack traces on your production sites for security reasons. However, this is more applicable to server-side errors (and Remix does indeed strip stack traces from server-side loader/action responses). In the case of client-side `react-router-dom` applications the code is already available in the browser anyway so any hiding is just security through obscurity. Furthermore, we would still want to expose the error in the console, so removing it from the UI display is still not hiding any information about the stack trace. Not showing it in the UI _and_ not logging it to the console would mean that application developers have no information _at all_ about production bugs, which poses its own set of issues. So, again we recommend you always add a root level `errorElement` before deploying your site to production!
5050

5151
## Throwing Manually
5252

@@ -77,13 +77,13 @@ Here's a "not found" case in a [loader][loader]:
7777

7878
As soon as you know you can't render the route with the data you're loading, you can throw to break the call stack. You don't have to worry about the rest of the work in the loader (like parsing the user's markdown bio) when it doesn't exist. Just throw and get out of there.
7979

80-
This also means you don't have to worry about a bunch of error branching code in your route component, it won't even try to render if you throw in the loader or action, instead your `errorElement` will render.
80+
This also means you don't have to worry about a bunch of error branching code in your route component. It won't even try to render if you throw in the loader or action, since your `errorElement` will render instead.
8181

8282
You can throw anything from a loader or action just like you can return anything: responses (like the previous example), errors, or plain objects.
8383

8484
## Throwing Responses
8585

86-
While you can throw anything and it will be provided back to you through [`useRouteError`][userouteerror], If you throw a [Response][response], React Router will automatically parse the response data before returning it to your components.
86+
While you can throw anything and it will be provided back to you through [`useRouteError`][userouteerror], if you throw a [Response][response], React Router will automatically parse the response data before returning it to your components.
8787

8888
Additionally, [`isRouteErrorResponse`][isrouteerrorresponse] lets you check for this specific type in your boundaries. Coupled with [`json`][json], you can easily throw responses with some data and render different cases in your boundary:
8989

docs/routers/create-browser-router.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ const router = createBrowserRouter(routes, {
116116

117117
The following future flags are currently available:
118118

119-
| Flag | Description |
120-
| ------------------------ | --------------------------------------------------------------------- |
121-
| `v7_fetcherPersist` | Delay active fetcher cleanup until they return to an `idle` state |
122-
| `v7_normalizeFormMethod` | Normalize `useNavigation().formMethod` to be an uppercase HTTP Method |
123-
| `v7_partialHydration` | Support partial hydration for Server-rendered apps |
124-
| `v7_prependBasename` | Prepend the router basename to navigate/fetch paths |
119+
| Flag | Description |
120+
| ------------------------------------------- | --------------------------------------------------------------------- |
121+
| `v7_fetcherPersist` | Delay active fetcher cleanup until they return to an `idle` state |
122+
| `v7_normalizeFormMethod` | Normalize `useNavigation().formMethod` to be an uppercase HTTP Method |
123+
| `v7_partialHydration` | Support partial hydration for Server-rendered apps |
124+
| `v7_prependBasename` | Prepend the router basename to navigate/fetch paths |
125+
| [`v7_relativeSplatPath`][relativesplatpath] | Fix buggy relative path resolution in splat routes |
125126

126127
## `hydrationData`
127128

@@ -197,3 +198,4 @@ Useful for environments like browser devtool plugins or testing to use a differe
197198
[query]: ./create-static-handler#handlerqueryrequest-opts
198199
[clientloader]: https://remix.run/route/client-loader
199200
[hydratefallback]: ../route/hydrate-fallback-element
201+
[relativesplatpath]: ../hooks/use-resolved-path#splat-paths

packages/react-router-dom-v5-compat/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<BrowserRouter>
109109
<Routes>
110110
<Route path="dashboard">
111-
<Route path="*" element={<Dashboard />} />
111+
<Route index path="*" element={<Dashboard />} />
112112
</Route>
113113
</Routes>
114114
</BrowserRouter>

packages/react-router-dom/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<BrowserRouter>
109109
<Routes>
110110
<Route path="dashboard">
111-
<Route path="*" element={<Dashboard />} />
111+
<Route index path="*" element={<Dashboard />} />
112112
</Route>
113113
</Routes>
114114
</BrowserRouter>

packages/react-router-native/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<BrowserRouter>
109109
<Routes>
110110
<Route path="dashboard">
111-
<Route path="*" element={<Dashboard />} />
111+
<Route index path="*" element={<Dashboard />} />
112112
</Route>
113113
</Routes>
114114
</BrowserRouter>

packages/react-router/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<BrowserRouter>
109109
<Routes>
110110
<Route path="dashboard">
111-
<Route path="*" element={<Dashboard />} />
111+
<Route index path="*" element={<Dashboard />} />
112112
</Route>
113113
</Routes>
114114
</BrowserRouter>

0 commit comments

Comments
 (0)