preactjs / preact-router

:earth_americas: URL router for Preact.
http://npm.im/preact-router
MIT License
1.01k stars 156 forks source link

Match and activeClassName not working on page load. #412

Open three-fourteen opened 2 years ago

three-fourteen commented 2 years ago

I'm using custom history with "createHashHistory" and the page URL is something like "example.com/dash?id=3&token=tokenValue". When the page load and activeClassName from doesn't workg but as soon as navigate through the menu start working. Also, the back and forward from the brower it's a little bit buggy, while the URL is updated, Match, activeClassName and the router don't always work as expected.

developit commented 2 years ago

Can you re-test this with the recently-released preact-router version 4?

developit commented 2 years ago

The initial page load issue may be addressed via #416. The activeClassName and Match usage should be fixed by #416 though.

three-fourteen commented 2 years ago

Sorry I didn't reply but I due to the lack of response and requirement was pretty simple I opted for using a custom solution for the router. Thanks anyway.

orangecoloured commented 2 years ago

I've just tested and it's working. No need to put a component inside a router anymore to use useRouter and the activeClassName works properly.

ArcadeRenegade commented 1 year ago

I am still seeing this behavior in v4.1.0

activeClassName does not work for a default route on page load.