-
Notifications
You must be signed in to change notification settings - Fork 250
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
Leave hook is not called when url Param changes in parameterized Route #302
Comments
So is this a bug or a misconception from my side? Any feedback would be appreciated. |
Reproduced here for demonstration: https://runkit.com/embed/taaeebzc3mt2 |
Hey @jackiems82 @rjgamble, Navigo checks based on the |
Hey @krasimir, In our use case, we want to perform some disposal operations when we know we're leaving a page. In our implementation, |
I see. In such cases I usually question whether such logic needs to be in the routing layer. Is it possible to shift it in another place. |
Thank you for the feedback @krasimir. We added some guard handling on top of the leave hook to prevent losing unsaved changes. All of this works great on non-parameterized routes. But for a page where you can display editable documents in tabs it would not work. If you say it should be implemented outside of the general routing logic I need to see how I could implement that in our wrapping logic. |
I just checked that the before hook is always fired. Maybe I can use that for my purposes |
Its a good question. Unfortunately in our case, the routing layer is the only option we have for detecting that navigation event and performing that disposal and cleanup. Not to mention, execution in the hooks already provides us with all the context we need to perform our cleanup. |
The before hook was not an option because the rendering already started which looked odd. I have a workaround where I use a promise that is resolved by the user in a modal before the actual call to .navigate() happens. No need to rely on any hooks. For my scenario it is sufficient atm. But who knows what comes up later. |
Hi, I have a problem that the leave hook seems not to be called for routes with parameters when navigating to the "same" route but with different parameter.
The same actually happens for query parameters. I would've expected that any navigate call also calls the hooks.
The text was updated successfully, but these errors were encountered: