-
-
Notifications
You must be signed in to change notification settings - Fork 851
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
feat: provide location in onEnter/onStay/onLeave hooks #3622
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 406cec6.
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/create-router
@tanstack/create-start
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-router
@tanstack/react-router-with-query
@tanstack/react-start
@tanstack/react-start-api-routes
@tanstack/react-start-client
@tanstack/react-start-config
@tanstack/react-start-plugin
@tanstack/react-start-router-manifest
@tanstack/react-start-server
@tanstack/react-start-server-functions-client
@tanstack/react-start-server-functions-fetcher
@tanstack/react-start-server-functions-handler
@tanstack/react-start-server-functions-ssr
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-start
@tanstack/solid-start-api-routes
@tanstack/solid-start-client
@tanstack/solid-start-config
@tanstack/solid-start-plugin
@tanstack/solid-start-router-manifest
@tanstack/solid-start-server
@tanstack/solid-start-server-functions-client
@tanstack/solid-start-server-functions-fetcher
@tanstack/solid-start-server-functions-handler
@tanstack/solid-start-server-functions-ssr
@tanstack/start
@tanstack/start-config
@tanstack/start-server-functions-server
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
a0d83cb
to
e6aef99
Compare
017c52c
to
e0dae9b
Compare
@@ -191,6 +191,27 @@ describe('onEnter event', () => { | |||
|
|||
expect(fn).toHaveBeenCalledWith({ foo: 'bar' }) | |||
}) | |||
|
|||
it('should have location defined in router.load()', async () => { |
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.
rather should have location defined in onEnter
?
please also add a test for onStay and onLeave
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.
also applies to react-router of course
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.
Was just copying the style from above
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.
its in an onEnter describe block
packages/router-core/src/route.ts
Outdated
@@ -865,6 +865,7 @@ export interface UpdatableRouteOptions< | |||
>, | |||
TLoaderDeps | |||
>, | |||
{ location }: { location: ParsedLocation<{}> }, |
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.
we should be able to supply the search type here (same for the others as well)
probably makes sense to create a type OnMatchOptions<TSearch> = {location:ParsedLocation<TSearch>
and use this for all 3 methods?
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.
i think this additional typing is a little out of my immediate grasp - can you give some more guidance
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.
before we do that, what is the semantic of location in each of these hooks?
I think in case of onLeave location is anything BUT the match, so we cannot statically type the search here.
whereas for the other hooks, the route's search is present in location
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.
Its the location that will resolve (assuming nothing thrown) - played with current / next like the useBlocker stuff but decided on this approach.
9d71302
to
e285bbe
Compare
wrong but as a starting point
768968a
to
879b53b
Compare
@schiller-manuel how do you want to reconcile this? |
https://discord.com/channels/719702312431386674/1345441363831033960