Today, if you display prerendered html (usually via dangerouslySetInnerHTML) that contains <a> tags that refer to a relative path, those links obviously will not get intercepted by react router. This in my opinion is a real bummer for consuming for example a wordpress api.
To be honest I'm not sure if the feature I want to request is even possible, but it would be great if you could either somehow attach to anchor tags containing relative links to route them on the client or intercept every leave and check for the destination and redirect if it's a 'local' link.
Those DOM nodes aren't connected to React at all. We have no (reasonable) way of accessing them.
You could probably achieve that by using document.getElementsByTagName('a') inside the lifecycle methods and then add click listeners that call router.push, similar to how Link does it.
I don't think this is a much requested feature, and it goes against the design/best practices of the router and react, so it probably shouldn't be part of the router itself.
Most helpful comment
You could probably achieve that by using
document.getElementsByTagName('a')inside the lifecycle methods and then add click listeners that callrouter.push, similar to how Link does it.I don't think this is a much requested feature, and it goes against the design/best practices of the router and react, so it probably shouldn't be part of the router itself.