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

onChange event triggers only after URL change, unable to abort route transition before URL change #428

Open
Aadhisivam opened this issue Jul 18, 2022 · 3 comments

Comments

@Aadhisivam
Copy link

I would like to abort route transition based on certain conditions , so i utilised onChange event , but it triggers only after URL change.
I can abort transition in that event, but the url hash is changed which is irrelevant of the current route.

Is there any way to block this behaviour ?

@Aadhisivam
Copy link
Author

Edit : Cant Abort onChange event also

@tanjim-rahat
Copy link

Adding a setTimeout worked for me

const onRoute = async ev => {
      switch (ev.path) {
          case '/login': {
              if (auth == true) setTimeout(() => route('/home', true), 0)
          }
      }
  }

@akornatskyy
Copy link

the route cannot be used as the active router is registered in ROUTERS when it mounted (that means at the time you call route, the ROUTES is empty list); so instead you can use ev.router.routeTo(...).

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