Repository navigation
fix(tanstack-router): reselect useStore when the selector changes - #971
Merged
Merged
Conversation
Cache snapshots by atom, selector, and comparator as well as store input so a captured parent match id is re-evaluated after navigation publishes the new match list. Nested Outlets no longer stay empty between sibling parameterized routes. Fixes #962 Co-authored-by: Jon Wheeler <[email protected]>
jonkwheeler
marked this pull request as ready for review
September 6, 2026 13:50
leonidaz
approved these changes
Sep 6, 2026
Closed
15 of 24 tasks
14 of 21 tasks
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.
Fixes #962
Summary
useStorekept the previous selection whenever the atom value was unchanged, even if the selector (or atom/comparator) had changed.parentId. After sibling table navigation,matchesIdhad already published, so the new selector never ran and the nested outlet stayed empty.Why
/tables/users→/tables/ordersleft the child outlet empty until reload.['new', 'new-child']withparentIdstill'old', updating toparentId: 'new'without another publish returnedundefinedinstead of'new-child'.Changes
packages/tanstack-router/src/useStore.ts: invalidate the snapshot cache when the selector, atom, or comparator changes.Validation
pnpm format:check(not run; used scopedpnpm format:fileson the changed paths)pnpm typecheck(not run repo-wide;pnpm typecheck:fileson the changed paths reports pre-existing errors inhooks.tsrx/PreviousRouterValueBoundary, not in this diff)pnpm test(not run repo-wide)vitest run --project tanstack-router— 84 passed, including the new store-selection and sibling-table Outlet casesvitest run --project tanstack-router-ssr— 7 passed'none'instead of'new-child'; sibling table navigation lost.table-rowsafter/tables/users→/tables/ordersRisk / follow-ups
compareto keep snapshot identity. That matches Outlet and the previous allocating-selector contract.pnpm syncproduced no generated drift.Reviewers
READY FOR REVIEW. Requested reviews from @leonidaz and @trueadm.
Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.