-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inadvertent support for partial dynamic parameters (#9506)
* fix: ensure consistency in generatePath/compilePath for partial splat params * Do not match partial dynamic parameters
- Loading branch information
1 parent
3778eac
commit 9a35285
Showing
6 changed files
with
146 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
"react-router": patch | ||
"@remix-run/router": patch | ||
--- | ||
|
||
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: | ||
|
||
```jsx | ||
// Old behavior at URL /prefix-123 | ||
<Route path="prefix-:id" element={<Comp /> }> | ||
|
||
function Comp() { | ||
let params = useParams(); // { id: '123' } | ||
let id = params.id; // "123" | ||
... | ||
} | ||
|
||
// New behavior at URL /prefix-123 | ||
<Route path=":id" element={<Comp /> }> | ||
|
||
function Comp() { | ||
let params = useParams(); // { id: 'prefix-123' } | ||
let id = params.id.replace(/^prefix-/, ''); // "123" | ||
... | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters