Skip to content

Commit 2a370af

Browse files
committed
Draft release notes
1 parent ec173d8 commit 2a370af

File tree

2 files changed

+215
-92
lines changed

2 files changed

+215
-92
lines changed

.changeset/neat-candles-stare.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ import { type RouteConfig, route } from "@react-router/dev/routes";
1313

1414
export default [
1515
route("parent/:p", "routes/parent.tsx", [
16-
route("route/:r", "routes/route.tsx", [
16+
route("layout/:l", "routes/layout.tsx", [
1717
route("child1/:c1a/:c1b", "routes/child1.tsx"),
1818
route("child2/:c2a/:c2b", "routes/child2.tsx"),
1919
]),
2020
]),
2121
] satisfies RouteConfig;
2222
```
2323

24-
Previously, `params` for `routes/route` were calculated as `{ p: string, r: string }`.
24+
Previously, `params` for the `routes/layout.tsx` route were calculated as `{ p: string, l: string }`.
2525
This incorrectly ignores params that could come from child routes.
26-
If visiting `/parent/1/route/2/child1/3/4`, the actual params passed to `routes/route` will have a type of `{ p: string, r: string, c1a: string, c1b: string }`.
26+
If visiting `/parent/1/layout/2/child1/3/4`, the actual params passed to `routes/layout.tsx` will have a type of `{ p: string, l: string, c1a: string, c1b: string }`.
2727

2828
Now, `params` are aware of child routes and autocompletion will include child params as optionals:
2929

3030
```ts
3131
params.|
3232
// ^ cursor is here and you ask for autocompletion
3333
// p: string
34-
// r: string
34+
// l: string
3535
// c1a?: string
3636
// c1b?: string
3737
// c2a?: string
3838
// c2b?: string
3939
```
4040

41-
You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/route`:
41+
You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/layout.tsx`:
4242

4343
```ts
4444
if (typeof params.c1a === 'string') {
4545
params.|
4646
// ^ cursor is here and you ask for autocompletion
4747
// p: string
48-
// r: string
48+
// l: string
4949
// c1a: string
5050
// c1b: string
5151
}

0 commit comments

Comments
 (0)