Repository navigation
feat(router-core): pass destination location to route lifecycle hooks - #8774
isihigameKoudai wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
onEnter, onStay and onLeave only received the route match, so consumers could not tell which URL/search the navigation was resolving to. Add a RouteLifecycleContext second argument carrying the destination ParsedLocation, dispatch it from both the client and server lifecycle runners, and document the new argument.
52da503 to
6fa49a9
Compare
🦋 Changeset detectedLatest commit: 6fa49a9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🎯 Changes
Closes #7778.
onEnter,onStayandonLeaveonly received the route match, so a consumer could not see the URL/search the navigation was resolving to. This adds aRouteLifecycleContextsecond argument carrying the destinationParsedLocation:locationis the destination in all three phases: the newly matched branch foronEnter/onStay, the destination that replaces the leaving route foronLeave.Implementation:
route.ts: exportedRouteLifecycleContext({ location: ParsedLocation }), updated the three hook signatures.router.ts:runRouteLifecycletakes the destination and passes{ location }to every hook.load-client.ts: dispatch withrouter.stores.location.get(), which holds the destination at commit time.load-server.ts: dispatch with the server-sidenextlocation.index.ts: export the type.@tanstack/router-core.One-parameter hooks keep working; nothing else changes behaviour.
✅ Checklist
Local verification (not run in CI-equivalent full mode):
eslinton the touched files reports 41 pre-existing problems, identical before and after the change (git stashcomparison). I did not run the React/Solid/Vue e2e suites here, so CI is the source of truth for those.New tests:
tests/lifecycle-dispatch.test.tscovers all three hooks receiving the destination;tests/callbacks.test.tsnow asserts the destinationhrefper hook (onLeavefrom/foo→/bar,onStaywith a changed search). Existing stubs/benchmarks were updated for the new internal signature.🚀 Release Impact
AI assistance disclosure: implemented with an AI agent (Hermes) on my machine; I reviewed the diff, ran the tests above, and can maintain the change.
Summary by CodeRabbit
New Features
RouteLifecycleContexttype for accessing destination details.Documentation
Tests