Skip to content

Commit

Permalink
fix: avoid double load in strict mode
Browse files Browse the repository at this point in the history
Fixes #861
  • Loading branch information
tannerlinsley committed Dec 28, 2023
1 parent 62848ad commit ae55158
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/react-router/src/RouterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function RouterProvider<
}

function Transitioner() {
const mountLoadCount = React.useRef(0)
const router = useRouter()
const routerState = useRouterState({
select: (s) =>
Expand Down Expand Up @@ -203,7 +204,8 @@ function Transitioner() {
])

useLayoutEffect(() => {
if (!window.__TSR_DEHYDRATED__) {
if (!window.__TSR_DEHYDRATED__ && !mountLoadCount.current) {
mountLoadCount.current++
tryLoad()
}
}, [])
Expand Down

0 comments on commit ae55158

Please sign in to comment.