Skip to content

Commit

Permalink
fix: non ssr initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Dec 5, 2023
1 parent 9a88468 commit 89d525a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/react-router/src/RouterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ function RouterProviderInner<
router.startReactTransition = startReactTransition

const tryLoad = () => {
if (state.location !== router.latestLocation) {
startReactTransition(() => {
try {
router.load()
} catch (err) {
console.error(err)
}
})
}
startReactTransition(() => {
try {
router.load()
} catch (err) {
console.error(err)
}
})
}

useLayoutEffect(() => {
const unsub = router.history.subscribe(() => {
router.latestLocation = router.parseLocation(router.latestLocation)
tryLoad()
if (state.location !== router.latestLocation) {
tryLoad()
}
})

const nextLocation = router.buildLocation({
Expand Down

0 comments on commit 89d525a

Please sign in to comment.