-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple active elements post scaffold? #33
Comments
This is a bug in Vite's preview mode, it only ever serves You'll need to write a plugin if you want the preview server to act correctly, unfortunately. Here's what we use for the Preact website The two active links at once is therefore a hydration error that comes from this mismatch (using the wrong HTML doc for the path). |
I see. Thanks for the information. |
We'll land something in |
|
Describe the issue
Create a starter project, build it with SSR enabled. The scaffold contains a sample
<Header />
component with multiplenav
links.In
dev
mode, when you initially load a route, or you navigate to another route fromnav
links or you just hitenter
in the URL bar: in all 3 cases theactive
route is highlighted correctly.If you
build
andpreview
it, then:localhost:4173/about/
, the correctnav
link is highlighted. Continuing on clicking on other links, correct active routes are also highlighted. Also, if you create a route as say/profile
(not absence of forward-slash), it'll continue to correctly highlight the active routelocalhost:4173/about
(note the absence of a forward-slash), then only the link associated with the root path i.e./
orHome
is highlighted. Continuing to click on any other route exceptHome
preservesHome
highlighted while also marking the other routes as active, i.e. at any point in time 2 routes are active, which is incorrect. Only after when you click onHome
i.e. root route/
, and then click on other routes, you get the actual behaviour of only one active route being highlighted.Steps
yarn create preact
and create a project (ensure you usessr
)yarn build && yarn preview
Expectation
Irrespective of SSR or non-SSR, only one route should be active and be highlighted. If you
log
theurl
andpath
attributes fromuseLocation
, it correctly emits the current URL address. I presume it has something to do with rendering not picking up the correct path. But that too is contradictory since I have correctly useduseEffect
onpath
as dependency to update the document title.The text was updated successfully, but these errors were encountered: