-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Hydration mismatch for useId
#25755
Comments
Would you be able to provide a reproduction? 🙏 More infoWhy do I need to provide a reproduction?Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. What will happen?If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritize it based on its severity and how many people we think it might affect. If How can I create a reproduction?We have a couple of templates for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/starter/tree/v3-stackblitz A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as minimal as possible. See more details in our guide. You might also find these other articles interesting and/or helpful: |
Same here 👍 <script lang="ts" setup>
// ...
const uniqueIdentifier = useId();
// ...
</script>
<template>
<input
:id="uniqueIdentifier"
v-model="field"
v-bind="$attrs"
/>
</template>
<style scoped></style> This workaround helped, ofc as temp solution const uniqueIdentifier = useId().replace(':', '_'); |
I've had that in my project when using client-only and fallback inside of it (needed to render empty input). Fixed by removing client-only and by relying on hydration end. |
I have a reproduction link here, with @manchenkoff's suggestion: https://stackblitz.com/edit/github-rq89e8?file=app.vue,components%2FTestId.vue This way you don't get the hydration mismatch warning, but you still get the warning added here
@manniL, @danielroe are there any plans to support |
We need the ability to v-bind attrs to the root element as |
Why do you need them on the root element? It's not uncommon to have custom form elements that have a wrapper div with input/label nested inside where you need the attrs to be bound to the input. And even then, the attributes are still available (just not on the root element), no? |
It is because of the mechanics of how we ensure a stable ID that matches between server and client. Of course there are other locations they could be stored, but how can the composable 'know' where to access them? |
maybe we can pass a |
I believe it's because of how the useId composable was implemented, it had different separators. It is fixed in this commit. |
It is still producing this issue as of nuxt 3.11.0, the problem is that the return statement at the bottom of the packages/nuxt/src/app/composables/id.ts file has a different separator than the one specified at the top in a constant
@manniL can you fix this as well please? |
@gregdev00 no, see #26315 |
Can this be closed then? |
I'm still getting this error in various components (not all):
There still seem to be cases, where a different seperator character is used ( I think it happens in dynamically loaded components.
|
Environment
Reproduction
Describe the bug
I got this warn when fully reload the page that use
useId
composable.Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: