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
Stop incorrectly matching on partial named parameters, i.e. `<Route path="prefix-:param">`, to align with how splat parameters work. If you were previously relying on this behavior then it's recommended to extract the static portion of the path at the `useParams` call site:
7
+
8
+
```jsx
9
+
// Old behavior at URL /prefix-123
10
+
<Route path="prefix-:id" element={<Comp /> }>
11
+
12
+
functionComp() {
13
+
let params =useParams(); // { id: '123' }
14
+
let id =params.id; // "123"
15
+
...
16
+
}
17
+
18
+
// New behavior at URL /prefix-123
19
+
<Route path=":id" element={<Comp /> }>
20
+
21
+
functionComp() {
22
+
let params =useParams(); // { id: 'prefix-123' }
23
+
let id =params.id.replace(/^prefix-/, ''); // "123"
"Route path \\"foo*\\" will be treated as if it were \\"foo/*\\" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to \\"foo/*\\".",
87
+
],
88
+
Array [
89
+
"Route path \\"/foo*\\" will be treated as if it were \\"/foo/*\\" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to \\"/foo/*\\".",
90
+
],
91
+
Array [
92
+
"Route path \\"foo*\\" will be treated as if it were \\"foo/*\\" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to \\"foo/*\\".",
93
+
],
94
+
Array [
95
+
"Route path \\"/foo*\\" will be treated as if it were \\"/foo/*\\" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to \\"/foo/*\\".",
"Route path \\"/prefix*\\" will be treated as if it were \\"/prefix/*\\" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to \\"/prefix/*\\".",
321
+
],
322
+
Array [
323
+
"Route path \\"/prefix*\\" will be treated as if it were \\"/prefix/*\\" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to \\"/prefix/*\\".",
324
+
],
325
+
]
326
+
`);
327
+
328
+
consoleWarn.mockRestore();
329
+
});
278
330
});
279
331
280
332
describe("path matchine with optional segments",()=>{
0 commit comments