Is there a recommended alternative to disableAutomaticLinkInterception
?
#1577
Replies: 1 comment 1 reply
-
Actually, I'm going to mark this as closed. As I think about it more clearly, although my app is a single-page app, because I'm not currently using Vike for the SPA routing (I'm using react-router), Vike should actually be configured to be server routing, and not client routing. And lo and behold, configuring vike to server routing, does solve the issue without the use of |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
In my project I am currently using react-router during the transition phase. There's a strange quirk I have noticed with one of the third party libraries though, which uses jQuery to do some dom manipulation, which unfortunately means that some react-router
Link
click handlers get removed during an edge case.Prior to Vike, using these disconnected links this would result in a full browser refresh - not the best experience, but at least functional. With Vike in the mix and set to clientRouting enabled, I notice that
onLinkClick()
handler handles the link click and attempts to do client side navigation.Because I am expecting react-router to handle the click (which it doesn't because the handler gets removed as a result of the dom manipulation), I am not expecting Vike's router to handle any routing. Looking for a way to disable it completely, I stumbled upon the
window._disableAutomaticLinkInterception
flag, and that does the trick to exit early from Vike'sonLinkClick()
handler!However, I did also notice a comment outlining that flag will be removed with the upcoming major release.
vike/vike/client/client-routing-runtime/skipLink.ts
Line 20 in 80cad76
Is there an alternative to disabling Vike's link interception? I have been exploring the
onBeforeRoute()
hook, and will also see if configuring Vike with server routing, instead of client routing (because in reality, it doesn't matter if I am using react-router for now) might do the trick.I'd like to avoid using undocumented/unofficial APIs such as
window._disableAutomaticLinkInterception
because they can always subject to change, but it really solves the issue I'm facing in a fairly clean manner.PS. the intention is to remove the problematic library so that we aren't falling victim to the DOM manipulation, so what I'm exploring here is also a temporary/short term fix.
Beta Was this translation helpful? Give feedback.
All reactions