Skip to content

beforeRouteEnter Callback Invoked Multiple Times #1610

@wdews

Description

@wdews

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions