Uh oh!
There was an error while loading. Please reload this page.
fix(router-core): onStay callback should use 'current' matches not 'previous' - #5485
Conversation
WalkthroughThe stayingMatches computation in packages/router-core/src/router.ts was changed to derive stayingMatches by filtering Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant Router
participant Matches as Match Engine
App->>Router: navigate() / onReady()
Router->>Matches: compute previousMatches
Router->>Matches: compute newMatches
note right of Router: Old flow
Router->>Router: stayingMatches = previousMatches ∩ newMatches (by id)
Router->>Router: enteringMatches = newMatches - stayingMatches
Router->>Router: exitingMatches = previousMatches - stayingMatches
Router-->>App: invoke onEnter/onStay/onLeave
sequenceDiagram
autonumber
participant App
participant Router
participant Matches as Match Engine
App->>Router: navigate() / onReady()
Router->>Matches: compute previousMatches
Router->>Matches: compute newMatches
note right of Router: New flow (this PR)
Router->>Router: stayingMatches = newMatches ∩ previousMatches (by id)
Router->>Router: enteringMatches = newMatches - stayingMatches
Router->>Router: exitingMatches = previousMatches - stayingMatches
Router-->>App: invoke onEnter/onStay/onLeave
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
SeanCassiere
left a comment
There was a problem hiding this comment.
Could you please add a test to make sure this behaviour is being enforced?
onStay callback should use 'current' matches not 'previous'View your CI Pipeline Execution ↗ for commit decb4dd
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter@tanstack/directive-functions-plugin@tanstack/eslint-plugin-router@tanstack/history@tanstack/nitro-v2-vite-plugin@tanstack/react-router@tanstack/react-router-devtools@tanstack/react-router-ssr-query@tanstack/react-start@tanstack/react-start-client@tanstack/react-start-server@tanstack/router-cli@tanstack/router-core@tanstack/router-devtools@tanstack/router-devtools-core@tanstack/router-generator@tanstack/router-plugin@tanstack/router-ssr-query-core@tanstack/router-utils@tanstack/router-vite-plugin@tanstack/server-functions-plugin@tanstack/solid-router@tanstack/solid-router-devtools@tanstack/solid-router-ssr-query@tanstack/solid-start@tanstack/solid-start-client@tanstack/solid-start-server@tanstack/start-client-core@tanstack/start-plugin-core@tanstack/start-server-core@tanstack/start-static-server-functions@tanstack/start-storage-context@tanstack/valibot-adapter@tanstack/virtual-file-routes@tanstack/zod-adaptercommit: |
TeChn4K
commented
Nov 1, 2025
Added! @SeanCassiere |
Uh oh!
There was an error while loading. Please reload this page.
This PR fixes#1901
onStayroute hook currently gives the previousmatchinstead of the current one.Now, same as
onEnterhook, you get the currentmatchSummary by CodeRabbit
Bug Fixes
Tests