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.

router.push() behaving differently than g-link

See original GitHub issue

Description

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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
mnlmaiercommented, Aug 21, 2019

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 😃

0reactions
platform-kitcommented, Jun 27, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

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