router.push() behaving differently than g-link
See original GitHub issueDescription
router.push()
doesn’t unmount the layout
Steps to reproduce
add an action to the mounted
hook of the layout and notice that it’s always called when navigating via g-link
but not when navigating via push()
Expected result
Mounting/unmounting should behave consistently for both cases
Actual result
g-link
unmounts/mounts the layout, push()
doesn’t
Notes
To be honest, I don’t even know if this is a bug or just something I wasn’t able to find in the docs. I would like to programmatically navigate between pages with the same behavior as it would occur when clicking on a g-link
. Any ideas? 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Next.JS "Link" vs "router.push()" vs "a" tag - Stack Overflow
router.push('/push') behaves similarly to window.location. ... router.push() is mostly used in an event handler ( onClick here).
Read more >Router support | Reference - BootstrapVue
Denotes the target route of the link. When clicked, the value of the to prop will be passed to router.push() internally, so the...
Read more >Routing: Linking and Navigating - Next.js beta docs
Learn how to use the Link Component, useRouter Hook, and navigate between routes ... A route transition is initiated using <Link> or calling...
Read more >Host Links Installation and Configuration - Gallagher & Robertson AS
be used to connect G&R/Glink (for Windows or Java) emulators ... During installation you are given the choice of installing on a different...
Read more >How to Use Vue Router: A Complete Tutorial - Vue School Blog
When you navigate to /profile route or /product route you can see no new javascript is being loaded. This is because all the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just a quick heads up: Of course, the issue was not related to the router itself – i was using a template to create pages based on and filled with graphql content, which did not trigger the Vue hooks I was expecting since the actual template would not be updated on route change.
To solve this, I am now using a randomly generated key (or something like
Date.now()
) as a prop on the components I want to update to trigger a forced update on each route change.Maybe someone will find this helpful 😃
@mnlmaier or @hjvedvik , could either of you shed some light on what exactly determines whether a component is re-rendered upon route change?
My mounted() code doesn’t seem to run when I use g-link, but does run if it’s the first page loaded.