preact-router
preact-router copied to clipboard
<Link> causes double render when used with custom history
Currently using preact-router v2.6.0
With a router configured like: <Router history="createHashHistory()">...</Router>
and a link like: <Link href="/foo">Foo</Link>
, the content of the router gets rendered twice.
Cause is here: a history item is pushed (causing a render), then the router is routed to the route (causing a second render).
I haven't found a straightforward way around this, but I'd love to know if I've overlooked something.
Actually, possibly a deeper issue.
If you look here, it seems straightforward that an event listener for popState
should only be added if we don't have a custom history, but in our situation we do. Somehow popState
is getting bound to anyway.
Nevermind, was able to step into preact router code, and popState
is not bound. Please disregard my last comment.
@bgradin just to clarify - are you doing <Router history="createHashHistory()">
? or did you mean <Router history={createHashHistory()}>
?