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.

Help! @Watch can not watch '$router' in Typecript

See original GitHub issue
  @Watch('id')
  public getLinksFromRoute (val: any, old: any) {
     console.log(1); // worked
  }
  @Watch('$route')
  public getLinksFromRoute (val: Route, old: Route) {
     console.log(1); // not worked
  }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
loferreiranunocommented, May 8, 2020

@Watch(‘$route’, { immediate: true, deep: true } ) onRouteChange (to: any, from: any) { console.log(to) this.photoId = to.params.id }

2reactions
Nicholas-Westleycommented, Oct 31, 2018

@CloseGillter47 It works if ‘deep’ is set to true. @Watch('$route', {deep: true})

@foxbunny What is recommended way to react to route changes?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Watch('$router') is not fired and throws exception
I'm diving deeper into Vue + Typescript. It was fine until I faced an issue with router. My app structure is:.
Read more >
Getting Started with React Router 6 and Typescript [2022]
React router 5 was awesome, and react router 6 is even better!Commands used:create-react-app react- router -6 --template=typescriptnpm install ...
Read more >
Building a Web app with Vue Router, Typescript ... - YouTube
Today we will be looking at using Vue Router with the composition API, to create a cat facts webpage with full typescript support....
Read more >
TypeScript support in Svelte - Learn web development
In this article we took our to-do list application and ported it to TypeScript.
Read more >
next/router | Next.js
If you want to access the router object inside any function component in your app, you can use the useRouter hook, take a...
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