fix: restore immediate state sync so useIsPending works during transitions#78
Closed
fix: restore immediate state sync so useIsPending works during transitions#78
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useIsPendingnever returningtrueduring transitions caused by a suspending route. TheentryInitValuesentinel delegatedlocationEntrytouseSyncExternalStore, which always reflects the latest adapter snapshot — even in a transition's fallback render — so React could never show the old route withisPending=true.setLocationEntry(adapter.getSnapshot())call in the subscription effect (removed in 4a4ef2c as "redundant"), which locks a real value intouseStatebefore any navigation, givingstartTransitiona proper old state to fall back to.entryInitValueindirection (Symbolsentinel,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 failinguseIsPending > returns true when a navigation transition is pending due to a suspending route🤖 Generated with Claude Code