wouter
wouter copied to clipboard
v3.0.0-rc.1: When use hash router, Ctrl+click on <Link>, new window is opened with wrong url
3.0.0-rc.1
<Router hook={useHashLocation}>
<Link to="/abc">link text</Link>
</Router>
Click the link, windows location is changed to https://example.com/#/abc
as expected.
Ctrl+click, a new tab is opened at https://example.com/abc#/abc
Yeah, that is a long known problem that we don't have a solution for yet. This might be a duplicate of https://github.com/molefrog/wouter/issues/215, could you take a look?
I use following code to work around:
const HashLink = ({ to, children }: { to: string, children: React.ReactNode }) => {
return (
<a href={'#' + to}>
{children}
</a>
)
}
Seems that the problem is we cannot get the composed URL with current useLocation
API.
Hello everyone, the support for this has finally landed in 3.1.0. Thank you for participating in this discussion. https://github.com/molefrog/wouter/releases/tag/v3.1.0