Skip to content

Commit

Permalink
fix(react-router): fix transitions (#2969)
Browse files Browse the repository at this point in the history
* fix(react-router): fix transitions

fixes #2631
fixes #2082

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
schiller-manuel and autofix-ci[bot] authored Dec 9, 2024
1 parent 950b80f commit 359ab15
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/react-router/src/Transitioner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function Transitioner() {
select: ({ isLoading }) => isLoading,
})

const [isTransitioning, startReactTransition_] = React.useTransition()
const [isTransitioning, setIsTransitioning] = React.useState(false)
// Track pending state changes
const hasPendingMatches = useRouterState({
select: (s) => s.matches.some((d) => d.status === 'pending'),
Expand All @@ -27,7 +27,13 @@ export function Transitioner() {
const previousIsPagePending = usePrevious(isPagePending)

if (!router.isServer) {
router.startReactTransition = startReactTransition_
router.startReactTransition = (fn: () => void) => {
setIsTransitioning(true)
React.startTransition(() => {
fn()
setIsTransitioning(false)
})
}
}

// Subscribe to location changes
Expand Down

0 comments on commit 359ab15

Please sign in to comment.