Skip to content
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

When two Link components are nested within each other, it reports "Hydration completed but contains mismatches." #4495

Closed
4 tasks done
chiaweilee opened this issue Jan 17, 2025 · 1 comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@chiaweilee
Copy link

chiaweilee commented Jan 17, 2025

Describe the bug

When two Link components are nested within each other, it reports "Hydration completed but contains mismatches."
This error only occurs in the production environment.

Link.vue:

<template>
  <a>
    <slot />
  </a>
</template>

index.md

<Link><Link>Hydration completed but contains mismatches.</Link></Link>

Reproduction

https://stackblitz.com/edit/vite-4nxfvzn6?file=docs%2Findex.md

Expected behavior

I'm not sure why this happens, but it's quite hard to troubleshoot. It would be better if more explicit error messages could be provided.

System Info

Latest Chrome

Additional context

No response

Validations

@chiaweilee chiaweilee added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 17, 2025
@brc-dd
Copy link
Member

brc-dd commented Jan 17, 2025

Because it is invalid HTML - https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element

Transparent, but there must be no interactive content descendant, a element descendant, or descendant with the tabindex attribute specified.

Regarding better errors, it is there while developing:

Image


(Edit: sorry these are not there when you've invalid HTML across components, you'll need to enable DEBUG mode to see those in browser console in prod build).

If you want errors on prod build, you can run DEBUG=true vitepress build which will enable __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ flag.

@brc-dd brc-dd closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants