Skip to content

Commit 61952ea

Browse files
committed
Merge branch 'dev' into johnpangalos/fix-use-location-for-background-routes
2 parents 5dcc570 + e13e1f9 commit 61952ea

File tree

146 files changed

+8411
-3219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+8411
-3219
lines changed

.changeset/afraid-games-laugh.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
fix: avoid uneccesary re-renders on defer resolution (#9155)

.changeset/beige-buckets-lick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"react-router-dom": patch
3+
"@remix-run/router": patch
4+
---
5+
6+
fix: pass useMatches objects to ScrollRestoration getKey (#9157)

.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 structure 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`

.changeset/calm-lies-destroy.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
"react-router": patch
3+
"react-router-dom": patch
4+
"@remix-run/router": patch
5+
---
6+
7+
fix: remove internal router singleton (#9227)
8+
9+
This change removes the internal module-level `routerSingleton` we create and maintain inside our data routers since it was causing a number of headaches for non-simple use cases:
10+
11+
- Unit tests are a pain because you need to find a way to reset the singleton in-between tests
12+
- Use use a `_resetModuleScope` singleton for our tests
13+
- ...but this isn't exposed to users who may want to do their own tests around our router
14+
- The JSX children `<Route>` objects cause non-intuitive behavior based on idiomatic react expectations
15+
- Conditional runtime `<Route>`'s won't get picked up
16+
- Adding new `<Route>`'s during local dev won't get picked up during HMR
17+
- Using external state in your elements doesn't work as one might expect (see #9225)
18+
19+
Instead, we are going to lift the singleton out into user-land, so that they create the router singleton and manage it outside the react tree - which is what react 18 is encouraging with `useSyncExternalStore` anyways! This also means that since users create the router - there's no longer any difference in the rendering aspect for memory/browser/hash routers (which only impacts router/history creation) - so we can get rid of those and trim to a simple `RouterProvider`
20+
21+
```jsx
22+
// Before
23+
function App() {
24+
<DataBrowserRouter>
25+
<Route path="/" element={<Layout />}>
26+
<Route index element={<Home />}>
27+
</Route>
28+
<DataBrowserRouter>
29+
}
30+
31+
// After
32+
let router = createBrowserRouter([{
33+
path: "/",
34+
element: <Layout />,
35+
children: [{
36+
index: true,
37+
element: <Home />,
38+
}]
39+
}]);
40+
41+
function App() {
42+
return <RouterProvider router={router} />
43+
}
44+
```
45+
46+
If folks still prefer the JSX notation, they can leverage `createRoutesFromElements` (aliased from `createRoutesFromChildren` since they are not "children" in this usage):
47+
48+
```jsx
49+
let routes = createRoutesFromElements(
50+
<Route path="/" element={<Layout />}>
51+
<Route index element={<Home />}>
52+
</Route>
53+
);
54+
let router = createBrowserRouter(routes);
55+
56+
function App() {
57+
return <RouterProvider router={router} />
58+
}
59+
```
60+
61+
And now they can also hook into HMR correctly for router disposal:
62+
63+
```
64+
if (import.meta.hot) {
65+
import.meta.hot.dispose(() => router.dispose());
66+
}
67+
```
68+
69+
And finally since `<RouterProvider>` accepts a router, it makes unit testing easer since you can create a fresh router with each test.
70+
71+
**Removed APIs**
72+
73+
- `<DataMemoryRouter>`
74+
- `<DataBrowserRouter>`
75+
- `<DataHashRouter>`
76+
- `<DataRouterProvider>`
77+
- `<DataRouter>`
78+
79+
**Modified APIs**
80+
81+
- `createMemoryRouter`/`createBrowserRouter`/`createHashRouter` used to live in `@remix-run/router` to prevent devs from needing to create their own `history`. These are now moved to `react-router`/`react-router-dom` and handle the `RouteObject -> AgnosticRouteObject` conversion.
82+
83+
**Added APIs**
84+
85+
- `<RouterProvider>`
86+
- `createRoutesFromElements` (alias of `createRoutesFromChildren`)

.changeset/cuddly-dingos-tickle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
fix: avoid navigation loops in <Navigate> re-renders in data routers (#9124)

.changeset/eighty-horses-leave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router-dom": patch
3+
---
4+
5+
fix: do not overwrite input value from button with same name (#9139)

.changeset/lucky-olives-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
fix: fix default redirect push/replace behavior (#9117)

.changeset/metal-hounds-remain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router-dom": patch
3+
---
4+
5+
fix: unspecified `<Form>` action should preserve search params (#9060)

.changeset/pre.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,49 @@
99
"@remix-run/router": "0.2.0-pre.0"
1010
},
1111
"changesets": [
12+
"afraid-games-laugh",
1213
"afraid-parents-laugh",
14+
"beige-buckets-lick",
15+
"big-bags-report",
1316
"brave-shirts-sneeze",
17+
"calm-lies-destroy",
1418
"chilled-beers-sell",
19+
"cuddly-dingos-tickle",
1520
"dirty-ladybugs-grow",
1621
"eighty-forks-search",
22+
"eighty-horses-leave",
1723
"fifty-ghosts-scream",
1824
"forty-phones-repair",
1925
"four-lobsters-crash",
2026
"gold-knives-drum",
2127
"gold-trains-rhyme",
2228
"light-months-argue",
2329
"lovely-tomatoes-smoke",
30+
"lucky-olives-wonder",
31+
"metal-hounds-remain",
2432
"new-kiwis-burn",
2533
"nine-stingrays-arrive",
2634
"ninety-spoons-suffer",
2735
"odd-yaks-kneel",
36+
"red-sheep-push",
37+
"shy-guests-tickle",
2838
"silver-planes-relate",
2939
"sixty-otters-teach",
3040
"slimy-pugs-sip",
3141
"strange-terms-pretend",
3242
"strong-bees-pay",
3343
"stupid-dryers-shout",
3444
"sweet-books-switch",
45+
"sweet-eggs-hug",
3546
"thick-lions-taste",
3647
"thirty-monkeys-cheer",
3748
"tough-zoos-cry",
3849
"tricky-falcons-peel",
3950
"unlucky-cows-rhyme",
40-
"weak-seas-kiss"
51+
"weak-seas-kiss",
52+
"wet-readers-mate",
53+
"wise-scissors-hug",
54+
"yellow-cherries-tell",
55+
"young-pumas-destroy"
4156
]
4257
}

.changeset/red-sheep-push.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"react-router": patch
3+
"react-router-dom": patch
4+
"@remix-run/router": patch
5+
---
6+
7+
fix: rename resetScroll -> preventScrollReset (#9199)

.changeset/shy-guests-tickle.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"react-router": patch
3+
"@remix-run/router": patch
4+
---
5+
6+
fix: Avoid suspense loops on promise aborted values (#9226)

.changeset/sweet-eggs-hug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
fix: fetcher submission revalidating fetchers using wrong key (#9166)

.changeset/wet-readers-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
fix: Await should fallback on route params navigations (#9181)

.changeset/wise-scissors-hug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
fix: use a push navigation on submission errors (#9162)

.changeset/yellow-cherries-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router-dom": patch
3+
---
4+
5+
fix: useFormAction should not include pathless splat portion (#9144)

.changeset/young-pumas-destroy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@remix-run/router": patch
3+
---
4+
5+
fix: proxy defer resolve/reject values through tracked promises (#9200)

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": ["react-app"],
33
"rules": {
4-
"import/first": 0
4+
"import/first": "off",
5+
"@typescript-eslint/consistent-type-imports": "error"
56
},
67
"overrides": [
78
{

contributors.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- chensokheng
1414
- chrisngobanh
1515
- christopherchudzicki
16+
- coryhouse
1617
- cvbuelow
1718
- david-crespo
1819
- edwin177
@@ -77,3 +78,9 @@
7778
- vikingviolinist
7879
- williamsdyyz
7980
- xavier-lc
81+
- fz6m
82+
- TkDodo
83+
- infoxicator
84+
- KostiantynPopovych
85+
- CanRau
86+
- dokeet

0 commit comments

Comments
 (0)