Skip to content

Commit 370fa47

Browse files
authored
fix middleware in data routers when used with createRoutesFromElements (#14357)
1 parent 75ae1d3 commit 370fa47

File tree

4 files changed

+154
-68
lines changed

4 files changed

+154
-68
lines changed

.changeset/slow-laws-do.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+
Support `middleware` prop on `<Route>` for usage with a data router via `createRoutesFromElements`

packages/react-router/__tests__/createRoutesFromChildren-test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe("creating routes from JSX", () => {
4040
"index": undefined,
4141
"lazy": undefined,
4242
"loader": undefined,
43+
"middleware": undefined,
4344
"path": "home",
4445
"shouldRevalidate": undefined,
4546
},
@@ -60,6 +61,7 @@ describe("creating routes from JSX", () => {
6061
"index": undefined,
6162
"lazy": undefined,
6263
"loader": undefined,
64+
"middleware": undefined,
6365
"path": "about",
6466
"shouldRevalidate": undefined,
6567
},
@@ -87,6 +89,7 @@ describe("creating routes from JSX", () => {
8789
"index": true,
8890
"lazy": undefined,
8991
"loader": undefined,
92+
"middleware": undefined,
9093
"path": undefined,
9194
"shouldRevalidate": undefined,
9295
},
@@ -107,6 +110,7 @@ describe("creating routes from JSX", () => {
107110
"index": undefined,
108111
"lazy": undefined,
109112
"loader": undefined,
113+
"middleware": undefined,
110114
"path": ":id",
111115
"shouldRevalidate": undefined,
112116
},
@@ -120,6 +124,7 @@ describe("creating routes from JSX", () => {
120124
"index": undefined,
121125
"lazy": undefined,
122126
"loader": undefined,
127+
"middleware": undefined,
123128
"path": "users",
124129
"shouldRevalidate": undefined,
125130
},
@@ -133,6 +138,7 @@ describe("creating routes from JSX", () => {
133138
"index": undefined,
134139
"lazy": undefined,
135140
"loader": undefined,
141+
"middleware": undefined,
136142
"path": "/",
137143
"shouldRevalidate": undefined,
138144
},
@@ -186,6 +192,7 @@ describe("creating routes from JSX", () => {
186192
"index": undefined,
187193
"lazy": undefined,
188194
"loader": [Function],
195+
"middleware": undefined,
189196
"path": "home",
190197
"shouldRevalidate": [Function],
191198
},
@@ -213,6 +220,7 @@ describe("creating routes from JSX", () => {
213220
"index": true,
214221
"lazy": undefined,
215222
"loader": undefined,
223+
"middleware": undefined,
216224
"path": undefined,
217225
"shouldRevalidate": undefined,
218226
},
@@ -226,6 +234,7 @@ describe("creating routes from JSX", () => {
226234
"index": undefined,
227235
"lazy": undefined,
228236
"loader": undefined,
237+
"middleware": undefined,
229238
"path": "users",
230239
"shouldRevalidate": undefined,
231240
},
@@ -241,6 +250,7 @@ describe("creating routes from JSX", () => {
241250
"index": undefined,
242251
"lazy": undefined,
243252
"loader": undefined,
253+
"middleware": undefined,
244254
"path": "/",
245255
"shouldRevalidate": undefined,
246256
},

0 commit comments

Comments
 (0)