Skip to content

Commit

Permalink
fix: avoid Warning: Empty string passed to getElementById() (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
schiller-manuel authored Dec 15, 2023
1 parent 905a708 commit a09ba16
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/react-router/src/RouterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ function Transitioner() {
})

if ((document as any).querySelector) {
const el = document.getElementById(
routerState.location.hash,
) as HTMLElement | null
if (el) {
el.scrollIntoView()
if (routerState.location.hash !== '') {
const el = document.getElementById(
routerState.location.hash,
) as HTMLElement | null
if (el) {
el.scrollIntoView()
}
}
}
router.pendingMatches = []
Expand Down

0 comments on commit a09ba16

Please sign in to comment.