question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

identifying shallow routing events

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:17
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
banerjeesouvikcommented, May 4, 2020

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 and routeChangeComplete 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 up

6reactions
braglecommented, May 23, 2020

I’ve created an RFC for this issue: #13276

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Next.js routeChangeStart and router events
Shallow routing allows you to make changes to the path of a page without running data fetching methods again. It helps retain the...
Read more >
Shallow Routing - Next.js
Shallow routing allows you to change the URL without running data fetching methods again, that includes getServerSideProps , getStaticProps , and ...
Read more >
Rails route for method on nested shallow resource
Seems like I'm putting it in the wrong place or missing something since it passes the event as :event_id instead of :id. Everything...
Read more >
How to Change URLs with Shallow Routing in Next.js - Netlify
Shallow routing is when you change your website's URL without re-running data fetching methods again. In the case of Next.js, it means you...
Read more >
Module ActionDispatch::Routing::Mapper::Resources - Rails API
Set shallow: false on a child resource to ignore a parent's shallow parameter. :shallow_path. Prefixes nested shallow routes with the specified path. scope ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found