identifying shallow routing events
See original GitHub issueI have an algolia search page that tracks state thru query string params. I use Router.replace(href, as, { shallow: true })
(though I’m using the next-routes
version) to update the URL.
I also track page views via Router.onRouteChangeComplete
.
Expected Behavior
I don’t want to track every query string update as a unique page view. Since shallow routing events are somewhat diff’t in nature to regular routing events, I think the onRouteChangeComplete
event should include a flag indicating if it was a shallow route change or not.
Another solution is if it passed the previous route & the new route together onRouteChangeComplete
.
Current Behavior
AFAIK there’s no way to differentiate shallow routing events from regular routing via the Router event listeners.
ATM the way I avoid tracking query string changes as page hits is to keep the current pathname stored in a variable, then do a quick check onRouteChangeComplete
to see whether it’s a page hit.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:17
- Comments:11 (7 by maintainers)
Top GitHub Comments
Can this issue be reopened? I think it is a good to have feature. In my case, I have some page transition animations which I am controlling from
routeChangeStart
androuteChangeComplete
events. Now, when I do a shallow push, these events are again called. As of now there is no definite way to identify if the route change is due to shallow routing. If this is not being worked by anyone, I will be happy to take it upI’ve created an RFC for this issue: #13276