diff --git a/packages/react-router/src/RouterProvider.tsx b/packages/react-router/src/RouterProvider.tsx index 41442d67b7f..a8f6f2588ff 100644 --- a/packages/react-router/src/RouterProvider.tsx +++ b/packages/react-router/src/RouterProvider.tsx @@ -142,16 +142,16 @@ function Transitioner() { } }) - const nextLocation = router.buildLocation({ - search: true, - params: true, - hash: true, - state: true, - }); - - if (routerState.location.href !== nextLocation.href) { - router.commitLocation({ ...nextLocation, replace: true }); - } + const nextLocation = router.buildLocation({ + search: true, + params: true, + hash: true, + state: true, + }) + + if (routerState.location.href !== nextLocation.href) { + router.commitLocation({ ...nextLocation, replace: true }) + } return () => { unsub()