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 386386- ValiantCat
387387- vdusart
388388- vesan
389+ - vezaynk
389390- VictorElHajj
390391- vijaypushkin
391392- vikingviolinist
Original file line number Diff line number Diff line change @@ -2090,14 +2090,21 @@ export function useScrollRestoration({
20902090 }
20912091
20922092 // 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+ }
21002102 }
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+ ) ;
21012108 }
21022109
21032110 // Don't reset if this navigation opted out
You can’t perform that action at this time.
0 commit comments