Skip to content

Commit aa26610

Browse files
committed
add changeset
1 parent cbdf772 commit aa26610

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.changeset/big-bags-report.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
"react-router": patch
3+
"react-router-dom": patch
4+
"react-router-native": patch
5+
---
6+
7+
feat: add `relative=path` option for url-relative routing (#9160)
8+
9+
Adds a `relative=path` option to navigation aspects to allow users to opt-into paths behaving relative to the current URL instead of the current route hierarchy. This is useful if you're sharing route patterns in a non-nested for UI reasons:
10+
11+
```jsx
12+
// Contact and EditContact do not share UI layout
13+
<Route path="contacts/:id" element={<Contact />} />
14+
<Route path="contacts:id/edit" element={<EditContact />} />
15+
16+
function EditContact() {
17+
return <Link to=".." relative="path">Cancel</Link>
18+
}
19+
```
20+
21+
Without this, the user would need to reconstruct the contacts/:id url using useParams and either hardcoding the /contacts prefix or parsing it from useLocation.
22+
23+
This applies to all path-related hooks and components:
24+
25+
- `react-router`: `useHref`, `useResolvedPath`, `useNavigate`, `Navigate`
26+
- `react-router-dom`: `useLinkClickHandler`, `useFormAction`, `useSubmit`, `Link`, `Form`
27+
- `react-router-native`: `useLinkPressHandler`, `Link`

0 commit comments

Comments
 (0)