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

Feature to prevent router redirects #539

Open
ArtemSBulgakov opened this issue Mar 3, 2023 · 3 comments
Open

Feature to prevent router redirects #539

ArtemSBulgakov opened this issue Mar 3, 2023 · 3 comments

Comments

@ArtemSBulgakov
Copy link

I use window.onbeforeunload event to prevent users from losing their form data when they try to close the page. But a user can click on <Link>, and they will be redirected to another page on the website. And there is no possibility to prevent it.

@ije
Copy link
Member

ije commented Mar 3, 2023

you can create your own link, then handles the redirect with onClick event, aleph provides the redirect function for page navigation as SPA

@ArtemSBulgakov
Copy link
Author

Ok, will use this method. Thank you!

@ije
Copy link
Member

ije commented Mar 3, 2023

you can get the redirect method by using useRouter hooks:

import { useRouter } from "aleph/react"

function App(){
  const { url, redirect } = useRouter()
}

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

2 participants