File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed
packages/react-router/lib/dom Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " react-router " : patch
3
+ ---
4
+
5
+ Do not throw if the url hash is not a valid URI component
Original file line number Diff line number Diff line change 386
386
- ValiantCat
387
387
- vdusart
388
388
- vesan
389
+ - vezaynk
389
390
- VictorElHajj
390
391
- vijaypushkin
391
392
- vikingviolinist
Original file line number Diff line number Diff line change @@ -2090,14 +2090,21 @@ export function useScrollRestoration({
2090
2090
}
2091
2091
2092
2092
// try to scroll to the hash
2093
- if ( location . hash ) {
2094
- let el = document . getElementById (
2095
- decodeURIComponent ( location . hash . slice ( 1 ) )
2096
- ) ;
2097
- if ( el ) {
2098
- el . scrollIntoView ( ) ;
2099
- return ;
2093
+ try {
2094
+ if ( location . hash ) {
2095
+ let el = document . getElementById (
2096
+ decodeURIComponent ( location . hash . slice ( 1 ) )
2097
+ ) ;
2098
+ if ( el ) {
2099
+ el . scrollIntoView ( ) ;
2100
+ return ;
2101
+ }
2100
2102
}
2103
+ } catch {
2104
+ warning (
2105
+ false ,
2106
+ `"${ location . hash . slice ( 1 ) } " is not a decodable element ID. The view will not scroll to it.`
2107
+ ) ;
2101
2108
}
2102
2109
2103
2110
// Don't reset if this navigation opted out
You can’t perform that action at this time.
0 commit comments