Skip to content

beforeRouteEnter does not set data on 2nd visit #1357

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

Closed
xxRockOnxx opened this issue Apr 20, 2017 · 4 comments
Closed

beforeRouteEnter does not set data on 2nd visit #1357

xxRockOnxx opened this issue Apr 20, 2017 · 4 comments

Comments

@xxRockOnxx
Copy link

Version

2.4.0

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

A bit hassle to do in a Bin. Minimal reproduction I can give is only this code and steps below:

beforeRouteEnter(to, from, next) {
  next(vm => vm.someData = 'data')
}
  • Have a component with that nav guard code
  • Load the page. (Data is set)
  • Press back button then press forward (Or visit other routes and visit the problem route again)
  • Page loads, data is not set.

What is expected?

someData is equal to data

What is actually happening?

someData is empty

@posva
Copy link
Member

posva commented Apr 20, 2017

you're probably looking for beforeRouteUpdate

@posva posva closed this as completed Apr 20, 2017
@xxRockOnxx
Copy link
Author

@posva if following the description of it from here

For example, for a route with dynamic params /foo/:id, when we
navigate between /foo/1 and /foo/2, the same Foo component instance
will be reused

well then, no.

Any route I go to, when I get back to that one it doesn't update the data.

I tried to isolate everything already to the point only router and that component only remains.

Currently still talking about it on gitter somehow.

doing console.log() on next(vm => console.log() .... code....) and on created, and mounted

only mounted and created has the same output. they both have the same _uid and same everything. but the output from next()'s console.log is still the same.

@posva
Copy link
Member

posva commented Apr 20, 2017

it may be #1322

@pulekies
Copy link

For anyone blocked by this issue, you may be able to get around it by observing $route and doing whatever updates you had planned in beforeRouteUpdate's next callback there.

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

No branches or pull requests

3 participants