When a user clicks on a link, it would be great if there was a way to cancel the transition. (My use case is a reminder for users to save their work before navigating away from the page.)
This is similar to what I've been using successfully in the past with gatsby-link. (Rather than call preventDefault straightaway, I first check to see if any changes have not being saved.)
<Link
to="/example-page/"
onClick={evt => evt.preventDefault()}
>
Example Link
</Link>
I've been trying to get this working with this package but haven't had any luck. Does anyone know if this is possible?
Cheers,
Alec
UPDATE: I did some debugging. It looks like preventDefault method is only called after shouldNavigate has already executed in TransitionLink.js As such, the page transition has already occurred by the time the halt is requested.
Hi all,
When a user clicks on a link, it would be great if there was a way to cancel the transition. (My use case is a reminder for users to save their work before navigating away from the page.)
This is similar to what I've been using successfully in the past with gatsby-link. (Rather than call preventDefault straightaway, I first check to see if any changes have not being saved.)
I've been trying to get this working with this package but haven't had any luck. Does anyone know if this is possible?
Cheers,
Alec
UPDATE: I did some debugging. It looks like
preventDefault
method is only called aftershouldNavigate
has already executed in TransitionLink.js As such, the page transition has already occurred by the time the halt is requested.