Skip to content

fix: restore immediate state sync so useIsPending works during transitions#78

Closed
uhyo wants to merge 1 commit intomasterfrom
fix/use-transition-is-pending
Closed

fix: restore immediate state sync so useIsPending works during transitions#78
uhyo wants to merge 1 commit intomasterfrom
fix/use-transition-is-pending

Conversation

@uhyo
Copy link
Owner

@uhyo uhyo commented Feb 7, 2026

Summary

  • Fixed useIsPending never returning true during transitions caused by a suspending route. The entryInitValue sentinel delegated locationEntry to useSyncExternalStore, which always reflects the latest adapter snapshot — even in a transition's fallback render — so React could never show the old route with isPending=true.
  • Restored the immediate setLocationEntry(adapter.getSnapshot()) call in the subscription effect (removed in 4a4ef2c as "redundant"), which locks a real value into useState before any navigation, giving startTransition a proper old state to fall back to.
  • Removed the entryInitValue indirection (Symbol sentinel, locationEntryInternal, ternary fallback) which is no longer needed with the immediate sync back in place.

Test plan

  • pnpm test:run — all 177 tests pass, including the previously failing useIsPending > returns true when a navigation transition is pending due to a suspending route

🤖 Generated with Claude Code

…tions

The `entryInitValue` sentinel made `locationEntry` delegate to
`useSyncExternalStore` (via `initialEntry`) until the first navigation
event committed. Because `useSyncExternalStore` always reflects the
latest adapter snapshot — even during a transition's fallback render —
React could never show the old route with `isPending=true`; instead the
suspending new route was rendered in both the transition and the fallback,
defeating `useTransition` entirely.

Fix by restoring the immediate `setLocationEntry(adapter.getSnapshot())`
call in the subscription effect (removed in 4a4ef2c as "redundant").
This locks a real value into `useState` before any navigation occurs, so
subsequent `startTransition` updates have a proper old state to fall back
to. With the immediate sync back, the `entryInitValue` indirection is no
longer needed and is removed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@uhyo uhyo closed this Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant