-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
It appears that anytime I set up beforeRouteEnter
on certain routes in my app, they get invoked multiple times. Worth noting that these callbacks are asynchronous (async beforeRouteEnter (...
)
Working on multiple apps, I've noticed a commonality between the two applications on this behavior: the amount of times the callback for beforeRouteEnter
gets invoked aligns with the depth of nested routes.
For example, if the route I'm visiting happens to be nested to a point where a total of 4 <router-view></router-view>
components are rendered, the callback, despite being added to the deepest-nested route, will be invoked 4 times.
This could be a coincidence and not necessarily have to do with the number of <router-view></router-view>
components that exist in the application, but I thought it might be worth sharing.
Could somebody point me in the right direction? In my development environment, hitting an API endpoint 4x as frequently as I need to is less of a concern. But once we roll this app out to production, that won't do.
Thanks in advance for your help. Let me know if I can provide any specific snippets of my code that would be helpful.