You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .changeset/neat-candles-stare.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,39 +13,39 @@ import { type RouteConfig, route } from "@react-router/dev/routes";
13
13
14
14
exportdefault [
15
15
route("parent/:p", "routes/parent.tsx", [
16
-
route("route/:r", "routes/route.tsx", [
16
+
route("layout/:l", "routes/layout.tsx", [
17
17
route("child1/:c1a/:c1b", "routes/child1.tsx"),
18
18
route("child2/:c2a/:c2b", "routes/child2.tsx"),
19
19
]),
20
20
]),
21
21
] satisfiesRouteConfig;
22
22
```
23
23
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 }`.
25
25
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 }`.
27
27
28
28
Now, `params` are aware of child routes and autocompletion will include child params as optionals:
29
29
30
30
```ts
31
31
params.|
32
32
// ^ cursor is here and you ask for autocompletion
33
33
// p: string
34
-
//r: string
34
+
//l: string
35
35
// c1a?: string
36
36
// c1b?: string
37
37
// c2a?: string
38
38
// c2b?: string
39
39
```
40
40
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`:
42
42
43
43
```ts
44
44
if (typeofparams.c1a==='string') {
45
45
params.|
46
46
// ^ cursor is here and you ask for autocompletion
0 commit comments