Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$navigator.path not up-to-date on mounted() after navigation #42

Open
coltonwood opened this issue Jun 17, 2020 · 3 comments
Open

$navigator.path not up-to-date on mounted() after navigation #42

coltonwood opened this issue Jun 17, 2020 · 3 comments

Comments

@coltonwood
Copy link

coltonwood commented Jun 17, 2020

I have a pretty simple setup:

  • A basic login component that calls this.$navigator.navigate('/landing').
  • The Landing component just console.logs this.$navigator.path within mounted and it spits out /login instead of /landing
  • The Landing template has a Label with $navigator.path and I see it update a split second after rendering, so it seems like there's just a delay when path is actually updated? I'm not sure.

Let me know if you need more details. The setup seems pretty basic, so maybe I'm just missing something obvious. I'd like to check if a component needs auth (in my meta prop of the route) on mounted, so that's my actual use case.

Note I'm on 1.2.0.

@coltonwood
Copy link
Author

After some more investigation, it looks like the $navigator.path is not updated (and therefore can't get meta options from route) until after the transition animation is complete.

Is this intended?

@rigor789
Copy link
Member

The path is updated when the Frame updates it's current page - which happens to be right when the transition finishes, which is after the mounted hook - so that part is expected.

I guess you should not navigate if the target needs auth, but that's not currently possible without manually reading the routes file and the meta. I'll think about a neat solution, perhaps a beforeNavigate hook where you can cancel/change the target route.

@coltonwood
Copy link
Author

Ooh yeah that could be pretty useful I think. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants