-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(router-core): onStay callback should use 'current' matches not 'previous'
#5485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-adapter
commit: |
Added! @SeanCassiere |
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